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

feat: initGlobal_NGT_02

parent 9194fbdb
// Learn cc.Class:
// - 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 { initGlobal_NGT_02 } from "../common/_preDefine";
import { asyncDelay, RandomInt, showFireworks } from "../common/utils";
var effect = cc.Class({
extends: cc.Component,
properties: {
},
properties: {},
ctor: function () {
initGlobal_NGT_02();
effect.inst = this;
g.effect = effect;
},
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();
},
showEffect2: function () {
const bg = cc.find('Canvas/bg/connent');
showFireworks(bg, cc.find('RibbonNodeBase').children, cc.v2(0, -400), cc.v2(0, 1000), 200, 200
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, cc.find('RibbonNodeBase').children, cc.v2(-600, -400), cc.v2(200, 1000), 200, 200
showFireworks(
bg,
cc.find("RibbonNodeBase").children,
cc.v2(-600, -400),
cc.v2(200, 1000),
200,
200
);
showFireworks(bg, cc.find('RibbonNodeBase').children, cc.v2(600, -400), cc.v2(-200, 1000), 200, 200
showFireworks(
bg,
cc.find("RibbonNodeBase").children,
cc.v2(600, -400),
cc.v2(-200, 1000),
200,
200
);
},
......@@ -45,12 +57,25 @@ var effect = cc.Class({
async showAllFirework(parentNode, nodeList) {
for (let i = 0; i < 6; i++) {
this.showFirework(cc.v2(0, -parentNode.height / 2), parentNode, nodeList, parentNode.width * 2 / 3, parentNode.height * 1.3);
this.showFirework(
cc.v2(0, -parentNode.height / 2),
parentNode,
nodeList,
(parentNode.width * 2) / 3,
parentNode.height * 1.3
);
await asyncDelay(0.1);
}
},
showFirework(pos, parentNode, nodeList, width = 200, height = 200, number = 30) {
showFirework(
pos,
parentNode,
nodeList,
width = 200,
height = 200,
number = 30
) {
for (let i = 0; i < number; i++) {
const quad = this.createQuads(pos, parentNode, nodeList);
const targetX = RandomInt(width / 2, -width / 2);
......@@ -62,15 +87,12 @@ var effect = cc.Class({
.start();
cc.tween(quad)
.by(0.5, { y: targetY }, { easing: 'quadOut' })
.to(4, { y: -parentNode.height * 2 }, { easing: 'quadIn' })
.by(0.5, { y: targetY }, { easing: "quadOut" })
.to(4, { y: -parentNode.height * 2 }, { easing: "quadIn" })
.removeSelf()
.start();
cc.tween(quad)
.delay(1)
.to(1.5, { opacity: 0 })
.start();
cc.tween(quad).delay(1).to(1.5, { opacity: 0 }).start();
}
},
......@@ -82,12 +104,12 @@ var effect = cc.Class({
quadBase.angle = RandomInt(180);
quadBase.parent = parentNode;
const quad = quadBase.getChildByName('quad');
const quad = quadBase.getChildByName("quad");
quad.x = 0;
quad.y = 0;
quad.angle = RandomInt(180);
const paper = quad.getChildByName('paper');
const paper = quad.getChildByName("paper");
paper.scaleX = Math.random() * 0.5 + 0.5;
paper.scaleY = Math.random() * 0.5 + 0.5;
......@@ -105,7 +127,6 @@ var effect = cc.Class({
})
.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