Commit f5ae3805 authored by 邱旭's avatar 邱旭

1

parent 47abbef1
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<e:Skin class="HbGame" width="750" height="1206" xmlns:e="http://ns.egret.com/eui" <e:Skin class="HbGame" width="750" height="1206" xmlns:e="http://ns.egret.com/eui"
xmlns:w="http://ns.egret.com/wing"> xmlns:w="http://ns.egret.com/wing">
<e:Group id="rainGroup" left="0" right="0" top="0" height="1206"/>
<e:Group right="40" top="45"> <e:Group right="40" top="45">
<e:Image y="0" source="hbGame_num_bg_png" horizontalCenter="0"/> <e:Image y="0" source="hbGame_num_bg_png" horizontalCenter="0"/>
<e:BitmapLabel id="numLabel" y="33" font="hbGameNumFont_fnt" text="0" horizontalCenter="0"/> <e:BitmapLabel id="numLabel" y="33" font="hbGameNumFont_fnt" text="0" horizontalCenter="0"/>
......
import Panel from "../../../libs/new_wx/components/Panel"; import Panel from "../../../libs/new_wx/components/Panel";
import RainMgr from "./RainMgr";
import CutTimer from "../../CutTimer";
/** /**
* 红包雨主游戏 * 红包雨主游戏
...@@ -9,19 +11,22 @@ export default class HbGame extends Panel { ...@@ -9,19 +11,22 @@ export default class HbGame extends Panel {
public readyGroup: eui.Group; public readyGroup: eui.Group;
public readyTips: eui.Image; public readyTips: eui.Image;
public readyCutTime: eui.Image; public readyCutTime: eui.Image;
public rainGroup: eui.Group;
private rainMgr: RainMgr = null;
private cutTime: CutTimer = null;
constructor(data) { constructor(data) {
super(); super();
this.data = data; this.data = data;
} }
start() { onLoad() {
super.start();
this.initUI(); this.initUI();
} }
initUI() { initUI() {
this.rainGroup.height = this.width / window.innerWidth * window.innerHeight;
} }
private readyTimeEffect() { private readyTimeEffect() {
...@@ -43,6 +48,7 @@ export default class HbGame extends Panel { ...@@ -43,6 +48,7 @@ export default class HbGame extends Panel {
egret.Tween.get(obj).to({scaleX: 1, scaleY: 1, alpha: 1}, t1, _ease).wait(tw).call(() => { egret.Tween.get(obj).to({scaleX: 1, scaleY: 1, alpha: 1}, t1, _ease).wait(tw).call(() => {
egret.Tween.get(obj).to({scaleX: _scaleMax, scaleY: _scaleMax, alpha: 0.1}, t2).call(() => { egret.Tween.get(obj).to({scaleX: _scaleMax, scaleY: _scaleMax, alpha: 0.1}, t2).call(() => {
this.readyGroup.visible = false; this.readyGroup.visible = false;
this.startGame();
}) })
}); });
}) })
...@@ -51,6 +57,19 @@ export default class HbGame extends Panel { ...@@ -51,6 +57,19 @@ export default class HbGame extends Panel {
}); });
} }
private startGame() {
this.rainMgr = new RainMgr({
parent: this,
rainGroup: this.rainGroup,
});
this.cutTime = new CutTimer(this.cutTimeLabel, 'ss', () => this.gameOver());
this.cutTime.start(59 * 1000);
}
private gameOver() {
}
private readyTipsEffect() { private readyTipsEffect() {
this.readyTips.alpha = 0; this.readyTips.alpha = 0;
egret.Tween.get(this.readyTips).to({alpha: 1}, 300).call(() => this.readyTimeEffect()); egret.Tween.get(this.readyTips).to({alpha: 1}, 300).call(() => this.readyTimeEffect());
...@@ -59,6 +78,7 @@ export default class HbGame extends Panel { ...@@ -59,6 +78,7 @@ export default class HbGame extends Panel {
protected onSkinComplete() { protected onSkinComplete() {
this.readyGroup.visible = false; this.readyGroup.visible = false;
setTimeout(() => this.readyTipsEffect(), 1000); setTimeout(() => this.readyTipsEffect(), 1000);
this.onLoad();
} }
initEvents() { initEvents() {
......
import RainObj from "./RainObj";
import RainData from "./RainData";
export default class RainMgr { export default class RainMgr {
private data; private data;
private parent; private parent;
...@@ -8,6 +11,15 @@ export default class RainMgr { ...@@ -8,6 +11,15 @@ export default class RainMgr {
this.parent = this.data.parent; this.parent = this.data.parent;
this.rainGroup = this.data.rainGroup; this.rainGroup = this.data.rainGroup;
this.start();
}
private start(){
let s = new RainObj({
key:RainData.key[~~(Math.random() * RainData.key.length)],
scale: 1,
rainGroup: this.rainGroup,
});
} }
......
...@@ -2,17 +2,26 @@ export default class RainObj { ...@@ -2,17 +2,26 @@ export default class RainObj {
private data = null; private data = null;
private module: eui.Image = null; private module: eui.Image = null;
private rainGroup = null;
constructor(data) { constructor(data) {
this.data = data; this.data = data;
this.module.source = `hbGame_${this.data.key}_png`; console.log(this.data);
this.module = new eui.Image(`hbGame_${this.data.key}_png`);
this.module.scaleX = this.module.scaleY = this.data.scale; this.module.scaleX = this.module.scaleY = this.data.scale;
this.rainGroup = this.data.rainGroup;
this.module.x = 100;
this.module.y = -100;
this.rainGroup.addChild(this.module);
this.start(); this.start();
} }
private start() { private start() {
this.module.addEventListener(egret.TouchEvent.TOUCH_TAP, this.touchTap, this); this.module.addEventListener(egret.TouchEvent.TOUCH_TAP, this.touchTap, this);
egret.Tween.get(this.module).to({rotation:360, loop:true}, 20000); egret.Tween.get(this.module, {loop: true}).to({rotation: ~~(Math.random() * 2) ? 360 : -360}, 18000);
egret.Tween.get(this.module).to({y: this.rainGroup.height}, 10000).call(() => this.destroy());
} }
private touchTap() { private touchTap() {
...@@ -21,8 +30,11 @@ export default class RainObj { ...@@ -21,8 +30,11 @@ export default class RainObj {
} }
private destroy() { private destroy() {
this.module.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.touchTap, this);
egret.Tween.removeTweens(this.module); egret.Tween.removeTweens(this.module);
this.module.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.touchTap, this);
this.module.source = `hbGame_${this.data.key}_touch_png`;
setTimeout(()=>{
this.rainGroup.removeChild(this.module);
}, 1000);
} }
} }
\ No newline at end of file
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