Commit e5789739 authored by 范雪寒's avatar 范雪寒

feat: initGlobal_NGT_02

parent 9194fbdb
// Learn cc.Class: import { initGlobal_NGT_02 } from "../common/_preDefine";
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { asyncDelay, RandomInt, showFireworks } from "../common/utils"; import { asyncDelay, RandomInt, showFireworks } from "../common/utils";
var effect = cc.Class({ var effect = cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {},
},
ctor: function () {
ctor: function () { initGlobal_NGT_02();
effect.inst = this; effect.inst = this;
g.effect = effect; g.effect = effect;
}, },
showEffect: function () { showEffect: function () {
const bg = cc.find('Canvas/bg/connent'); const bg = cc.find("Canvas/bg/connent");
this.showAllFirework(bg, cc.find('paperBase').children); this.showAllFirework(bg, cc.find("paperBase").children);
g.speaker.inst.play_congratulation(); g.speaker.inst.play_congratulation();
}, },
showEffect2: function () { showEffect2: function () {
const bg = cc.find('Canvas/bg/connent'); const bg = cc.find("Canvas/bg/connent");
showFireworks(bg, cc.find('RibbonNodeBase').children, cc.v2(0, -400), cc.v2(0, 1000), 200, 200 showFireworks(
); bg,
showFireworks(bg, cc.find('RibbonNodeBase').children, cc.v2(-600, -400), cc.v2(200, 1000), 200, 200 cc.find("RibbonNodeBase").children,
); cc.v2(0, -400),
showFireworks(bg, cc.find('RibbonNodeBase').children, cc.v2(600, -400), cc.v2(-200, 1000), 200, 200 cc.v2(0, 1000),
); 200,
}, 200
);
async showOneFirework(pos, parentNode, nodeList) { showFireworks(
for (let i = 0; i < 3; i++) { bg,
this.showFirework(pos, parentNode, nodeList, 200, 200, 15); cc.find("RibbonNodeBase").children,
await asyncDelay(0.1); cc.v2(-600, -400),
} cc.v2(200, 1000),
}, 200,
200
async showAllFirework(parentNode, nodeList) { );
for (let i = 0; i < 6; i++) { showFireworks(
this.showFirework(cc.v2(0, -parentNode.height / 2), parentNode, nodeList, parentNode.width * 2 / 3, parentNode.height * 1.3); bg,
await asyncDelay(0.1); cc.find("RibbonNodeBase").children,
} cc.v2(600, -400),
}, cc.v2(-200, 1000),
200,
showFirework(pos, parentNode, nodeList, width = 200, height = 200, number = 30) { 200
for (let i = 0; i < number; i++) { );
const quad = this.createQuads(pos, parentNode, nodeList); },
const targetX = RandomInt(width / 2, -width / 2);
const targetY = RandomInt(height); async showOneFirework(pos, parentNode, nodeList) {
for (let i = 0; i < 3; i++) {
cc.tween(quad) this.showFirework(pos, parentNode, nodeList, 200, 200, 15);
.by(0.5, { x: targetX }) await asyncDelay(0.1);
.by(3, { x: targetX * 2 }) }
.start(); },
cc.tween(quad) async showAllFirework(parentNode, nodeList) {
.by(0.5, { y: targetY }, { easing: 'quadOut' }) for (let i = 0; i < 6; i++) {
.to(4, { y: -parentNode.height * 2 }, { easing: 'quadIn' }) this.showFirework(
.removeSelf() cc.v2(0, -parentNode.height / 2),
.start(); parentNode,
nodeList,
cc.tween(quad) (parentNode.width * 2) / 3,
.delay(1) parentNode.height * 1.3
.to(1.5, { opacity: 0 }) );
.start(); await asyncDelay(0.1);
} }
}, },
createQuads(pos, parentNode, nodeList) { showFirework(
const quadBase = cc.instantiate(nodeList[RandomInt(nodeList.length)]); pos,
quadBase.x = pos.x; parentNode,
quadBase.y = pos.y; nodeList,
quadBase.z = pos.z; width = 200,
quadBase.angle = RandomInt(180); height = 200,
quadBase.parent = parentNode; number = 30
) {
const quad = quadBase.getChildByName('quad'); for (let i = 0; i < number; i++) {
quad.x = 0; const quad = this.createQuads(pos, parentNode, nodeList);
quad.y = 0; const targetX = RandomInt(width / 2, -width / 2);
quad.angle = RandomInt(180); const targetY = RandomInt(height);
const paper = quad.getChildByName('paper'); cc.tween(quad)
paper.scaleX = Math.random() * 0.5 + 0.5; .by(0.5, { x: targetX })
paper.scaleY = Math.random() * 0.5 + 0.5; .by(3, { x: targetX * 2 })
.start();
quadBase.scaleX = Math.random();
cc.tween(quadBase) cc.tween(quad)
.to((1 - quadBase.scaleX) * 0.3, { scaleX: 1 }) .by(0.5, { y: targetY }, { easing: "quadOut" })
.call(() => { .to(4, { y: -parentNode.height * 2 }, { easing: "quadIn" })
const time = Math.random() * 0.2; .removeSelf()
cc.tween(quadBase) .start();
.to(0.1 + time, { scaleX: -1 })
.to(0.1 + time, { scaleX: 1 }) cc.tween(quad).delay(1).to(1.5, { opacity: 0 }).start();
.union() }
.repeatForever() },
.start();
}) createQuads(pos, parentNode, nodeList) {
.start(); const quadBase = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
quadBase.x = pos.x;
quadBase.y = pos.y;
return quadBase; quadBase.z = pos.z;
}, quadBase.angle = RandomInt(180);
quadBase.parent = parentNode;
const quad = quadBase.getChildByName("quad");
quad.x = 0;
quad.y = 0;
quad.angle = RandomInt(180);
const paper = quad.getChildByName("paper");
paper.scaleX = Math.random() * 0.5 + 0.5;
paper.scaleY = Math.random() * 0.5 + 0.5;
quadBase.scaleX = Math.random();
cc.tween(quadBase)
.to((1 - quadBase.scaleX) * 0.3, { scaleX: 1 })
.call(() => {
const time = Math.random() * 0.2;
cc.tween(quadBase)
.to(0.1 + time, { scaleX: -1 })
.to(0.1 + time, { scaleX: 1 })
.union()
.repeatForever()
.start();
})
.start();
return quadBase;
},
}); });
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