Commit b42b48f9 authored by Li MingZhe's avatar Li MingZhe

fix: 底部宽度

parent 90456d83
No preview for this file type
No preview for this file type
No preview for this file type
{
"ver": "2.0.1",
"uuid": "c28e2c01-0a4a-4b28-b44e-7cf7c68f0ccf",
"downloadMode": 0,
"duration": 4.04898,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "5e66e21b-b845-488b-8dda-1bcb83c5262d",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { localPosTolocalPos } from "./util"; import { localPosTolocalPos, playAudio, showTrebleFirework} from "./util";
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
...@@ -182,9 +182,12 @@ cc.Class({ ...@@ -182,9 +182,12 @@ cc.Class({
}, },
_wrongAudioSource: null, _wrongAudioSource: null,
_gjAudioSource: null,
_endAudio: null,
initAudio() { initAudio() {
this._wrongAudioSource = cc.find('Canvas/res/wrong_audio').getComponent(cc.AudioSource); this._wrongAudioSource = cc.find('Canvas/res/wrong_audio').getComponent(cc.AudioSource);
this._gbAudioSource = cc.find('Canvas/res/good_job').getComponent(cc.AudioSource); this._gjAudioSource = cc.find('Canvas/res/good_job').getComponent(cc.AudioSource);
this._endAudio = cc.find('Canvas/res/end_audio').getComponent(cc.AudioSource);
}, },
initListener() { initListener() {
...@@ -560,6 +563,7 @@ cc.Class({ ...@@ -560,6 +563,7 @@ cc.Class({
mask.type = cc.Mask.Type.RECT; mask.type = cc.Mask.Type.RECT;
}, },
bottomPicArr: null,
initBottomPart() { initBottomPart() {
const bgBottom = cc.find('Canvas/bgBottom'); const bgBottom = cc.find('Canvas/bgBottom');
...@@ -572,6 +576,7 @@ cc.Class({ ...@@ -572,6 +576,7 @@ cc.Class({
} }
}); });
script.setItemData(picArr); script.setItemData(picArr);
this.bottomPicArr = picArr;
}, },
getBottomPicArr() { getBottomPicArr() {
...@@ -860,7 +865,15 @@ cc.Class({ ...@@ -860,7 +865,15 @@ cc.Class({
cc.audioEngine.stopAllEffects(); cc.audioEngine.stopAllEffects();
const audioID = cc.audioEngine.playEffect(animaNode.audioClip, false, 0.8); const audioID = cc.audioEngine.playEffect(animaNode.audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(audioID, () => { cc.audioEngine.setFinishCallback(audioID, () => {
this._gbAudioSource.play();
const gjId = cc.audioEngine.playEffect(this._gjAudioSource.clip, false, 0.8);
cc.audioEngine.setFinishCallback(gjId, () => {
const isEnd = this.checkGameEnd();
if (isEnd) {
this.gameEnd();
}
});
}); });
} }
...@@ -876,6 +889,31 @@ cc.Class({ ...@@ -876,6 +889,31 @@ cc.Class({
}, },
checkGameEnd() {
for (let i=0; i<this.hotzoneCircleArr.length; i++) {
if (this.hotzoneCircleArr[i].active) {
return false;
}
}
return true;
},
gameEnd() {
console.log('this.gameEnd');
this.playEndEffect();
},
playEndEffect() {
playAudio(this._endAudio.clip, 0.8);
const camera = cc.find('Canvas/Main Camera');
camera.zIndex = 100;
showTrebleFirework(camera, cc.find('RibbonNodeBase').children);
},
_curShowItem: null, _curShowItem: null,
bottomItemClick(item) { bottomItemClick(item) {
......
...@@ -70,9 +70,229 @@ export function setSprNodeMaxLen(sprNode, maxW, maxH) { ...@@ -70,9 +70,229 @@ export function setSprNodeMaxLen(sprNode, maxW, maxH) {
sprNode.scale = Math.round(s * 1000) / 1000; sprNode.scale = Math.round(s * 1000) / 1000;
} }
export function localPosTolocalPos(baseNode, targetNode) { export function localPosTolocalPos(baseNode, targetNode) {
const worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)); const worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y));
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y)); const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos; return localPos;
} }
export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
const worldRect1 = targetNode.getBoundingBoxToWorld();
const worldRect2 = baseNode.getBoundingBoxToWorld();
const sx = worldRect1.width / worldRect2.width;
const sy = worldRect1.height / worldRect2.height;
if (maxFlag) {
return Math.max(sx, sy);
} else {
return Math.min(sx, sy);
}
}
export function asyncCCLoad(resources) {
return new Promise((resolve, reject) => {
try {
cc.loader.load(resources, (error, assets) => {
resolve(assets)
});
} catch (e) {
reject(e);
}
});
}
export function loadDragonBones(image, atlas, ske, callback) {
Promise.all([
asyncCCLoad(image),
asyncCCLoad({ url: atlas, type: 'txt' }),
asyncCCLoad({ url: ske, type: 'txt' })
]).then(([texture, atlasJson, dragonBonesJson]) => {
callback(texture, atlasJson, dragonBonesJson);
}).catch((e) => {
console.log(e);
});
}
export async function playAudio(clip, volume = 1) {
return new Promise((resolve, reject) => {
try {
if (!clip) {
resolve();
return;
}
const id = cc.audioEngine.play(clip, false, volume);
cc.audioEngine.setFinishCallback(id, () => {
resolve();
});
} catch (e) {
reject(e);
}
});
}
export async function asyncDelay(time) {
return new Promise((resolve, reject) => {
try {
setTimeout(() => {
resolve();
}, time * 1000);
} catch (e) {
reject(e);
}
})
}
export class FireworkSettings {
baseNode; // 父节点
nodeList; // 火花节点的array
pos; // 发射点
side; // 发射方向
range; // 扩散范围
number; // 发射数量
scalseRange; // 缩放范围
constructor(baseNode, nodeList,
pos = cc.v2(0, 0),
side = cc.v2(0, 100),
range = 50,
number = 100,
scalseRange = 0
) {
this.baseNode = baseNode;
this.nodeList = nodeList;
this.pos = pos;
this.side = side;
this.range = range;
this.number = number;
this.scalseRange = scalseRange;
}
static copy(firework) {
return new FireworkSettings(
firework.baseNode,
firework.nodeList,
firework.pos,
firework.side,
firework.range,
firework.number,
);
}
}
export async function showFireworks(fireworkSettings) {
const { baseNode, nodeList, pos, side, range, number, scalseRange } = fireworkSettings;
new Array(number).fill(' ').forEach(async (_, i) => {
let rabbonNode = new cc.Node();
rabbonNode.parent = baseNode;
rabbonNode.x = pos.x;
rabbonNode.y = pos.y;
rabbonNode.angle = 60 * Math.random() - 30;
let node = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
node.parent = rabbonNode;
node.active = true;
node.x = 0;
node.y = 0;
node.angle = 0;
node.scale = (Math.random() - 0.5) * scalseRange + 1;
const rate = Math.random();
const angle = Math.PI * (Math.random() * 2 - 1);
await asyncTweenBy(rabbonNode, 0.3, {
x: side.x * rate + Math.cos(angle) * range * rate,
y: side.y * rate + Math.sin(angle) * range * rate
}, {
easing: 'quadIn'
});
cc.tween(rabbonNode)
.by(8, { y: -2000 })
.start();
cc.tween(rabbonNode)
.to(5, { scale: (Math.random() - 0.5) * scalseRange + 1 })
.start();
rabbonFall(rabbonNode);
await asyncDelay(Math.random());
cc.tween(node)
.by(0.15, { x: -10, angle: -10 })
.by(0.3, { x: 20, angle: 20 })
.by(0.15, { x: -10, angle: -10 })
.union()
.repeatForever()
.start();
cc.tween(rabbonNode)
.delay(5)
.to(0.3, { opacity: 0 })
.call(() => {
node.stopAllActions();
node.active = false;
node.parent = null;
node = null;
})
.start();
});
}
async function rabbonFall(node) {
const time = 1 + Math.random();
const offsetX = RandomInt(-200, 200) * time;
await asyncTweenBy(node, time, { x: offsetX, angle: offsetX * 60 / 200 });
rabbonFall(node);
}
export async function asyncTweenTo(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
try {
cc.tween(node)
.to(duration, obj, ease)
.call(() => {
resolve();
})
.start();
} catch (e) {
reject(e);
}
});
}
export async function asyncTweenBy(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
try {
cc.tween(node)
.by(duration, obj, ease)
.call(() => {
resolve();
})
.start();
} catch (e) {
reject(e);
}
});
}
export function showTrebleFirework(baseNode, rabbonList) {
const middle = new FireworkSettings(baseNode, rabbonList);
middle.pos = cc.v2(0, -400);
middle.side = cc.v2(0, 1000);
middle.range = 200;
middle.number = 100;
middle.scalseRange = 0.4;
const left = FireworkSettings.copy(middle);
left.pos = cc.v2(-600, -400);
left.side = cc.v2(200, 1000);
const right = FireworkSettings.copy(middle);
right.pos = cc.v2(600, -400);
right.side = cc.v2(-200, 1000);
showFireworks(middle);
showFireworks(left);
showFireworks(right);
}
{
"ver": "2.3.5",
"uuid": "ab873eda-ffb5-46e2-8e57-b0892030d3df",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 36,
"height": 24,
"platformSettings": {},
"subMetas": {
"bg_sahua": {
"ver": "1.0.4",
"uuid": "0735e431-fa61-49b9-a3b4-8927ff5ce7f4",
"rawTextureUuid": "ab873eda-ffb5-46e2-8e57-b0892030d3df",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 36,
"height": 24,
"rawWidth": 36,
"rawHeight": 24,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"__type__": "cc.SpriteFrame",
"content": {
"name": "bg_sahua",
"texture": "ab873eda-ffb5-46e2-8e57-b0892030d3df",
"atlas": "",
"rect": [
0,
0,
36,
24
],
"offset": [
0,
0
],
"originalSize": [
36,
24
],
"capInsets": [
0,
0,
0,
0
]
}
}
\ No newline at end of file
...@@ -189,9 +189,12 @@ cc.Class({ ...@@ -189,9 +189,12 @@ cc.Class({
}); });
}, },
_wrongAudioSource: null, _wrongAudioSource: null,
_gjAudioSource: null,
_endAudio: null,
initAudio: function initAudio() { initAudio: function initAudio() {
this._wrongAudioSource = cc.find('Canvas/res/wrong_audio').getComponent(cc.AudioSource); this._wrongAudioSource = cc.find('Canvas/res/wrong_audio').getComponent(cc.AudioSource);
this._gbAudioSource = cc.find('Canvas/res/good_job').getComponent(cc.AudioSource); this._gjAudioSource = cc.find('Canvas/res/good_job').getComponent(cc.AudioSource);
this._endAudio = cc.find('Canvas/res/end_audio').getComponent(cc.AudioSource);
}, },
initListener: function initListener() { initListener: function initListener() {
var _this6 = this; var _this6 = this;
...@@ -498,6 +501,7 @@ cc.Class({ ...@@ -498,6 +501,7 @@ cc.Class({
var mask = node.addComponent(cc.Mask); var mask = node.addComponent(cc.Mask);
mask.type = cc.Mask.Type.RECT; mask.type = cc.Mask.Type.RECT;
}, },
bottomPicArr: null,
initBottomPart: function initBottomPart() { initBottomPart: function initBottomPart() {
var bgBottom = cc.find('Canvas/bgBottom'); var bgBottom = cc.find('Canvas/bgBottom');
var script = bgBottom.getComponent('bgBottom'); var script = bgBottom.getComponent('bgBottom');
...@@ -508,6 +512,7 @@ cc.Class({ ...@@ -508,6 +512,7 @@ cc.Class({
} }
}); });
script.setItemData(picArr); script.setItemData(picArr);
this.bottomPicArr = picArr;
}, },
getBottomPicArr: function getBottomPicArr() { getBottomPicArr: function getBottomPicArr() {
var arr = []; // for (let i = 0; i < this.hotzoneCircleArr.length; i++) { var arr = []; // for (let i = 0; i < this.hotzoneCircleArr.length; i++) {
...@@ -764,7 +769,14 @@ cc.Class({ ...@@ -764,7 +769,14 @@ cc.Class({
cc.audioEngine.stopAllEffects(); cc.audioEngine.stopAllEffects();
var audioID = cc.audioEngine.playEffect(animaNode.audioClip, false, 0.8); var audioID = cc.audioEngine.playEffect(animaNode.audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(audioID, function () { cc.audioEngine.setFinishCallback(audioID, function () {
_this9._gbAudioSource.play(); var gjId = cc.audioEngine.playEffect(_this9._gjAudioSource.clip, false, 0.8);
cc.audioEngine.setFinishCallback(gjId, function () {
var isEnd = _this9.checkGameEnd();
if (isEnd) {
_this9.gameEnd();
}
});
}); });
} }
...@@ -777,6 +789,25 @@ cc.Class({ ...@@ -777,6 +789,25 @@ cc.Class({
}); });
}); });
}, },
checkGameEnd: function checkGameEnd() {
for (var i = 0; i < this.hotzoneCircleArr.length; i++) {
if (this.hotzoneCircleArr[i].active) {
return false;
}
}
return true;
},
gameEnd: function gameEnd() {
console.log('this.gameEnd');
this.playEndEffect();
},
playEndEffect: function playEndEffect() {
(0, _util.playAudio)(this._endAudio.clip, 0.8);
var camera = cc.find('Canvas/Main Camera');
camera.zIndex = 100;
(0, _util.showTrebleFirework)(camera, cc.find('RibbonNodeBase').children);
},
_curShowItem: null, _curShowItem: null,
bottomItemClick: function bottomItemClick(item) { bottomItemClick: function bottomItemClick(item) {
var _this10 = this; var _this10 = this;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"__type__": "cc.Texture2D",
"content": "0,9729,9729,33071,33071,0,0,1"
}
\ No newline at end of file
{
"__type__": "cc.AudioClip",
"_name": "end",
"_objFlags": 0,
"_native": ".mp3",
"duration": 4.04898,
"loadMode": 0
}
\ No newline at end of file
This diff is collapsed.
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
"main": true, "main": true,
"url": "app://editor/index.html", "url": "app://editor/index.html",
"windowType": "dockable", "windowType": "dockable",
"x": -1641, "x": -2385,
"y": -304, "y": -289,
"width": 1275, "width": 1275,
"height": 841, "height": 841,
"layout": { "layout": {
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
"3fjtSSnnNNBb9Db9xNkttL", "3fjtSSnnNNBb9Db9xNkttL",
"5aAwYeWN5GlpJJBm6cMCUR", "5aAwYeWN5GlpJJBm6cMCUR",
"2daSEONptJQLYU9aq8TOd+", "2daSEONptJQLYU9aq8TOd+",
"01Xreos21IrrsAvhvN44JE" "01Xreos21IrrsAvhvN44JE",
"2dxuR150xHc7HMMzQsLpMh"
] ]
} }
{"version":"1.0.8","stats":{"/Users/limingzhe/Documents/workspace/pro_hw/pro_cocos/cc_mz_003/play/temp/quick-scripts/src/__qc_index__.js":"2021-01-22T02:18:54.598Z","/Users/limingzhe/Documents/workspace/pro_hw/pro_cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/script/util.js":"2021-01-22T02:18:54.575Z","/Users/limingzhe/Documents/workspace/pro_hw/pro_cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/script/scene.js":"2021-01-22T02:18:54.574Z","/Users/limingzhe/Documents/workspace/pro_hw/pro_cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/prefab/bgBottom.js":"2021-01-22T02:18:54.577Z"}} {"version":"1.0.8","stats":{"/Users/limingzhe/Documents/workspace/pro_hw/pro_cocos/cc_mz_003/play/temp/quick-scripts/src/__qc_index__.js":"2021-01-22T03:00:25.521Z","/Users/limingzhe/Documents/workspace/pro_hw/pro_cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/script/util.js":"2021-01-22T03:00:25.500Z","/Users/limingzhe/Documents/workspace/pro_hw/pro_cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/script/scene.js":"2021-01-22T03:00:25.499Z","/Users/limingzhe/Documents/workspace/pro_hw/pro_cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/prefab/bgBottom.js":"2021-01-22T03:00:25.501Z"}}
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
function __define (exports, require, module) { function __define (exports, require, module) {
if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);} if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}
require('./assets/mz_003/prefab/bgBottom'); require('./assets/mz_003/prefab/bgBottom');
require('./assets/mz_003/script/runtime');
require('./assets/mz_003/script/scene'); require('./assets/mz_003/script/scene');
require('./assets/mz_003/script/util'); require('./assets/mz_003/script/util');
......
(function () { (function () {
var scripts = [{"deps":{"./assets/mz_003/script/scene":2,"./assets/mz_003/prefab/bgBottom":3,"./assets/mz_003/script/util":1},"path":"preview-scripts/__qc_index__.js"},{"deps":{},"path":"preview-scripts/assets/mz_003/script/util.js"},{"deps":{"./util":1},"path":"preview-scripts/assets/mz_003/script/scene.js"},{"deps":{"../script/util":1},"path":"preview-scripts/assets/mz_003/prefab/bgBottom.js"}]; var scripts = [{"deps":{"./assets/mz_003/script/runtime":4,"./assets/mz_003/prefab/bgBottom":3,"./assets/mz_003/script/util":1,"./assets/mz_003/script/scene":2},"path":"preview-scripts/__qc_index__.js"},{"deps":{},"path":"preview-scripts/assets/mz_003/script/util.js"},{"deps":{"./util":1},"path":"preview-scripts/assets/mz_003/script/scene.js"},{"deps":{"../script/util":1},"path":"preview-scripts/assets/mz_003/prefab/bgBottom.js"},{"deps":{},"path":"preview-scripts/assets/mz_003/script/runtime.js"}];
var entries = ["preview-scripts/__qc_index__.js"]; var entries = ["preview-scripts/__qc_index__.js"];
var bundleScript = 'preview-scripts/__qc_bundle__.js'; var bundleScript = 'preview-scripts/__qc_bundle__.js';
......
This diff is collapsed.
require('./assets/mz_003/prefab/bgBottom'); require('./assets/mz_003/prefab/bgBottom');
require('./assets/mz_003/script/runtime');
require('./assets/mz_003/script/scene'); require('./assets/mz_003/script/scene');
require('./assets/mz_003/script/util'); require('./assets/mz_003/script/util');
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment