基本信息
源码名称:egret黑白方块源码
源码大小:1.22M
文件格式:.rar
开发语言:js
更新时间:2017-12-07
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
egret游戏框架做的黑白方块游戏
class GameView extends egret.Sprite { public constructor() { super(); this.init(); } private _boxGroups:Array<BoxGroup>; //private scoreText:egret.TextField; private scoreText:egret.BitmapText; private init():void { this._boxGroups = []; var len:number = GameData.row 1; for(var i:number=0;i<len;i ) { var boxg:BoxGroup = new BoxGroup(); this._boxGroups.push(boxg); this.addChild(boxg); boxg.addEventListener(GameEvent.GAME_OVER, this.gameOver, this); boxg.addEventListener(GameEvent.GAME_HIT, this.gamehit, this); } /* this.scoreText = new egret.TextField(); this.scoreText.textColor = 0xff0000; this.scoreText.bold = true; this.scoreText.size = 100; */ this.scoreText = new egret.BitmapText(); this.scoreText.font = RES.getRes("number_fnt"); this.scoreText.x = 180; this.scoreText.y = 50; this.scoreText.text = String(0); this.addChild(this.scoreText); } public startgame():void { this.scoreText.text = String(0); var len:number = GameData.row 1; for(var i:number=0;i<len;i ) { this._boxGroups[i].create(); this._boxGroups[i].y = 0-GameData.getBoxHeight()*(1 i);//GameData.getStageHeight()-GameData.getBoxHeight()*(1 i); } } //移动 public move() { var len:number = GameData.row 1; for(var i:number=0;i<len;i ) { this._boxGroups[i].y = GameData.speed; } for(i=0;i<len;i ) { if(this._boxGroups[i].y>=GameData.getStageHeight())//移动到舞台外侧了 { if(!this._boxGroups[i].isHit) { this.gameOver(); return; } if(i==0) { this._boxGroups[i].y = this._boxGroups[4].y - GameData.getBoxHeight(); } else { this._boxGroups[i].y = this._boxGroups[i-1].y - GameData.getBoxHeight(); } this._boxGroups[i].create(); } } } private gameOver(evt:GameEvent=null):void { var event:GameEvent = new GameEvent(GameEvent.GAME_OVER); this.dispatchEvent(event); } private gamehit(evt:GameEvent):void { GameData.setScore(GameData.getScore() 1); this.scoreText.text = String(GameData.getScore()); } }