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,
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({ ...@@ -45,12 +57,25 @@ var effect = cc.Class({
async showAllFirework(parentNode, nodeList) { async showAllFirework(parentNode, nodeList) {
for (let i = 0; i < 6; i++) { 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); 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++) { for (let i = 0; i < number; i++) {
const quad = this.createQuads(pos, parentNode, nodeList); const quad = this.createQuads(pos, parentNode, nodeList);
const targetX = RandomInt(width / 2, -width / 2); const targetX = RandomInt(width / 2, -width / 2);
...@@ -62,15 +87,12 @@ var effect = cc.Class({ ...@@ -62,15 +87,12 @@ var effect = cc.Class({
.start(); .start();
cc.tween(quad) cc.tween(quad)
.by(0.5, { y: targetY }, { easing: 'quadOut' }) .by(0.5, { y: targetY }, { easing: "quadOut" })
.to(4, { y: -parentNode.height * 2 }, { easing: 'quadIn' }) .to(4, { y: -parentNode.height * 2 }, { easing: "quadIn" })
.removeSelf() .removeSelf()
.start(); .start();
cc.tween(quad) cc.tween(quad).delay(1).to(1.5, { opacity: 0 }).start();
.delay(1)
.to(1.5, { opacity: 0 })
.start();
} }
}, },
...@@ -82,12 +104,12 @@ var effect = cc.Class({ ...@@ -82,12 +104,12 @@ var effect = cc.Class({
quadBase.angle = RandomInt(180); quadBase.angle = RandomInt(180);
quadBase.parent = parentNode; quadBase.parent = parentNode;
const quad = quadBase.getChildByName('quad'); const quad = quadBase.getChildByName("quad");
quad.x = 0; quad.x = 0;
quad.y = 0; quad.y = 0;
quad.angle = RandomInt(180); quad.angle = RandomInt(180);
const paper = quad.getChildByName('paper'); const paper = quad.getChildByName("paper");
paper.scaleX = Math.random() * 0.5 + 0.5; paper.scaleX = Math.random() * 0.5 + 0.5;
paper.scaleY = Math.random() * 0.5 + 0.5; paper.scaleY = Math.random() * 0.5 + 0.5;
...@@ -105,7 +127,6 @@ var effect = cc.Class({ ...@@ -105,7 +127,6 @@ var effect = cc.Class({
}) })
.start(); .start();
return quadBase; 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