Commit fd873286 authored by shunx 马's avatar shunx 马

111

parent 3a570370
...@@ -13,67 +13,70 @@ let boxGroupUpRight = []; ...@@ -13,67 +13,70 @@ let boxGroupUpRight = [];
export class BoxGroup extends FYGE.Sprite { export class BoxGroup extends FYGE.Sprite {
constructor() { constructor() {
super(); super();
this.initBox(); this.initBox();
} }
initBox() { initBox() {
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
let box = new Box(); let box = new Box();
box.position.set(40, 0 + i * 238); box.position.set(40, 0 + i * 238);
box.addEventListener(FYGE.MouseEvent.CLICK, this.handleClick, this); box.addEventListener(FYGE.MouseEvent.CLICK, this.handleClick, this);
this.addChild(box); this.addChild(box);
boxGroupUpLeft.push(box); boxGroupUpLeft.push(box);
} }
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
let box = new Box(); let box = new Box();
box.position.set(230, 0 + i * 238); box.position.set(230, 0 + i * 238);
box.addEventListener(FYGE.MouseEvent.CLICK, this.handleClick, this); box.addEventListener(FYGE.MouseEvent.CLICK, this.handleClick, this);
this.addChild(box); this.addChild(box);
boxGroupDown.push(box); boxGroupDown.push(box);
} }
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
let box = new Box(); let box = new Box();
box.position.set(427, 0 + i * 238); box.position.set(427, 0 + i * 238);
box.addEventListener(FYGE.MouseEvent.CLICK, this.handleClick, this); box.addEventListener(FYGE.MouseEvent.CLICK, this.handleClick, this);
this.addChild(box); this.addChild(box);
boxGroupUpRight.push(box); boxGroupUpRight.push(box);
} }
} }
move() { move() {
const speed = 2; const speed = 2;
boxGroupUpLeft.forEach(i => { boxGroupUpLeft.forEach(i => {
i.y -= speed; i.y -= speed;
}) })
if (boxGroupUpLeft[0].y < -238 ) { if (boxGroupUpLeft[0].y < -238) {
boxGroupUpLeft[0].y = 238*3; boxGroupUpLeft[0].y = 238 * 3;
const popBox = boxGroupUpLeft.shift(); const popBox = boxGroupUpLeft.shift();
boxGroupUpLeft.push(popBox); boxGroupUpLeft.push(popBox);
}
boxGroupDown.forEach(i => {
i.y += speed;
if (i.y >= 623) {
i.y -= boxGroupDown.length * 238;
} }
boxGroupDown.forEach(i => {
i.y += speed;
if (i.y >= 623) {
i.y -= boxGroupDown.length * 238;
}
})
boxGroupUpRight.forEach(i => {
i.y -= speed;
}) })
if (boxGroupUpRight[0].y < -238 ) { boxGroupUpRight.forEach(i => {
boxGroupUpRight[0].y = 238*3; i.y -= speed;
const popBox = boxGroupUpRight.shift(); })
boxGroupUpRight.push(popBox); if (boxGroupUpRight[0].y < -238) {
boxGroupUpRight[0].y = 238 * 3;
const popBox = boxGroupUpRight.shift();
boxGroupUpRight.push(popBox);
} }
} }
handleClick() { handleClick(e) {
// const indexsvga = new FYGE.MovieClip(RES.getRes('盲盒开启-打开-输出.svga')); const indexsvga = new FYGE.MovieClip(RES.getRes('盲盒选中-输出.svga'));
// indexsvga.mouseChildren = indexsvga.mouseEnable = false; this.dispatchEvent("stopIndexEnterFrame", { isMove: false });
// // indexsvga.position.set(100,100) indexsvga.mouseChildren = indexsvga.mouseEnable = false;
// this.addChild(indexsvga); indexsvga.position.set(e.target.x-200,e.target.y-190)
showPanel(CostPanel); this.addChild(indexsvga);
} indexsvga.startAniRange(1, indexsvga.totalFrames, 1, () => {
showPanel(CostPanel);
});
}
} }
...@@ -70,12 +70,18 @@ export class IndexScene extends Scene { ...@@ -70,12 +70,18 @@ export class IndexScene extends Scene {
onEnterFrame() { onEnterFrame() {
boxGroup && boxGroup.move(); boxGroup && boxGroup.move();
boxGroup.addEventListener("stopIndexEnterFrame", this.removeEvent, this);
} }
toRule() { toRule() {
showPanel(RulePanel); showPanel(RulePanel);
} }
removeEvent() {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onEnterFrame, this);
}
getIndex = async () => { getIndex = async () => {
const result = await sendWebNet(WebNetName.projectIndex); const result = await sendWebNet(WebNetName.projectIndex);
if (!result.success) return; if (!result.success) return;
......
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