Commit f2407cef authored by wildfirecode13's avatar wildfirecode13

init

parent 3442846d
...@@ -15,6 +15,11 @@ export default class Enemy extends Movable implements IWeaponHost { ...@@ -15,6 +15,11 @@ export default class Enemy extends Movable implements IWeaponHost {
this.texture = FYGE.Texture.fromUrl('//yun.duiba.com.cn/spark/assets/enemy2_fly1.0f4acd3728e90763d98a7328a5a32dbc78ec204e.png') this.texture = FYGE.Texture.fromUrl('//yun.duiba.com.cn/spark/assets/enemy2_fly1.0f4acd3728e90763d98a7328a5a32dbc78ec204e.png')
const weapon = new Weapon(this); const weapon = new Weapon(this);
this.addEventListener(FYGE.Event.REMOVED_FROM_STAGE, () => {
console.log('敌人消失了')
weapon.destroy();
})
} }
getShootVelocity() { return new Vector2(0, 4) } getShootVelocity() { return new Vector2(0, 4) }
......
...@@ -11,14 +11,14 @@ export default class MovableManager { ...@@ -11,14 +11,14 @@ export default class MovableManager {
onEnterFrame = () => { onEnterFrame = () => {
this.step(); this.step();
this.checkRemove(); this.checkRemove();
// console.log('移动对象的数量:',this._movableList.length) console.log('移动对象的数量:',this._movableList.length)
} }
private calcCanRemove(item: FYGE.DisplayObject) { private calcCanRemove(item: FYGE.DisplayObject) {
if (item.y > 1624) return true; if (item.y > 1624) return true;
if (item.y < -item.height) return true; if (item.y < -item.height) return true;
if (item.x > 750) return true; if (item.x > 750) return true;
if (item.x < -item.width) return true; if (item.x < -item.width) return true;
return false; return false;
} }
...@@ -27,8 +27,8 @@ export default class MovableManager { ...@@ -27,8 +27,8 @@ export default class MovableManager {
const item = this._movableList[index]; const item = this._movableList[index];
if (this.calcCanRemove(item)) { if (this.calcCanRemove(item)) {
this._movableList.splice(index, 1); this._movableList.splice(index, 1);
item.parent && item.parent.removeChild(item);
index--; index--;
item.destroy();
} }
} }
} }
......
...@@ -14,7 +14,7 @@ export function addGame(stage: FYGE.Stage) { ...@@ -14,7 +14,7 @@ export function addGame(stage: FYGE.Stage) {
const enemy = stage.addChild(new Enemy(movableManager)); const enemy = stage.addChild(new Enemy(movableManager));
enemy.position.set(0, 0); enemy.position.set(0, 0);
enemy.velocity=new Vector2(1,1); enemy.velocity=new Vector2(4,1);
dragDropManager.add(hero); dragDropManager.add(hero);
} }
\ 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