Commit b188f161 authored by wildfirecode13's avatar wildfirecode13

1

parent 340d4506
import resCanvasList from "../../resCanvasList";
import { RES } from "../../module/RES"; import { RES } from "../../module/RES";
import { getStage } from "./stage"; import resCanvasList from "../../resCanvasList";
export default class DropItem extends FYGE.Sprite { export default class DropItem extends FYGE.Sprite {
constructor() { constructor() {
super(); super();
...@@ -8,17 +7,10 @@ export default class DropItem extends FYGE.Sprite { ...@@ -8,17 +7,10 @@ export default class DropItem extends FYGE.Sprite {
this.texture = RES.getRes( this.texture = RES.getRes(
resCanvasList["593e9d74-4944-496a-b6c1-8316756f8bf7"].url resCanvasList["593e9d74-4944-496a-b6c1-8316756f8bf7"].url
); );
this.y = 0;
getStage().addEventListener(
FYGE.Event.ENTER_FRAME,
this.onEnterFrame,
this
);
this.y= 0;
} }
onEnterFrame() { updatePosition() {
this.y +=10; this.y += 10;
} }
} }
import Root from "./Root";
import { getStage } from "./stage";
import DropItem from "./DropItem";
export default class DropsCtrl {
_root: Root;
_drops: DropItem[];
constructor(root) {
this._root = root;
}
start() {
getStage().addEventListener(
FYGE.Event.ENTER_FRAME,
this.onEnterFrame,
this
);
for (let index = 0; index < 10; index++) {
setTimeout(() => {
this.addDropItem();
}, 1000 * index);
}
}
addDropItem() {
this._drops = this._drops || [];
const drop = new DropItem();
this._root.addChild(drop);
drop.x = Math.random() * 400 + (750 - 400) / 2;
this._drops.push(drop);
}
onEnterFrame() {
if (this._drops) this._drops.forEach((drop) => drop.updatePosition());
}
destroy() {
getStage().removeEventListener(
FYGE.Event.ENTER_FRAME,
this.onEnterFrame,
this
);
}
}
import { RES } from "../../module/RES"; import { RES } from "../../module/RES";
import resCanvasList from "../../resCanvasList"; import resCanvasList from "../../resCanvasList";
import DropItem from "./DropItem"; import DropsCtrl from "./DropsCtrl";
export default class Root extends FYGE.Container { export default class Root extends FYGE.Container {
constructor() { constructor() {
super(); super();
...@@ -14,7 +15,8 @@ export default class Root extends FYGE.Container { ...@@ -14,7 +15,8 @@ export default class Root extends FYGE.Container {
); );
this.addChild(bg); this.addChild(bg);
this.addChild(new DropItem()) const ctrl = new DropsCtrl(this);
ctrl.start();
// SvgaParser.loadSvga( // SvgaParser.loadSvga(
// "//yun.duiba.com.cn/spark/assets/open_effect.b997f18f52ca96abb0913ca32fdce6f22ad9bcf7.svga", // "//yun.duiba.com.cn/spark/assets/open_effect.b997f18f52ca96abb0913ca32fdce6f22ad9bcf7.svga",
......
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