With a few days to develop the game, now back finishing Knowledge
First attach the source code, Download
http://www.521100.net/forum.php?mod=viewthread&tid=26&extra=page%3D1
1.Egret main loop for implementing business logic game progress update
egret.lifecycle.addLifecycleListener((context) => { context.onUpdate = () => { if(!this.init) { return; } if(this.player1) { this.player1.move(); } this.doEnemyAI(); this.handleBullet(); } })
2. Collision Detection
this.player1.hitTestPoint(bullet.x, bullet.y)
3. The random number generating
public randomNum(minNum:number,maxNum:number){ switch(arguments.length){ case 1: return Math.random()*minNum+1; case 2: return Math.random()*(maxNum-minNum+1)+minNum; default: return 0; } }
4. Click event handler
Open
bg.touchEnabled = true; bg.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBgTouch, this);
Approach
/ * In response to the click event context * / Private onBgTouch (E) { the let X = e.stageX; the let Y = e.stageY; the this .player1.targetX = the parseInt (X); the this .player1.targetY = the parseInt (Y) ; }
5. draw a pattern, circular
var shp:egret.Shape = new egret.Shape(); shp.graphics.beginFill( 0xffff00, 1); shp.graphics.drawCircle(0, 0, 5); shp.graphics.endFill(); this.addChild(shp);
6. Load a picture
private createBitmapByName(name: string) { let result = new egret.Bitmap(); let texture: egret.Texture = RES.getRes(name); result.texture = texture; return result; }