scene=new Sprite();
addChild(scene);
swapChildren(scene,mcGameInfo);
bmpData=new BitmapData(mc.width,mc.height);
bmpData.draw(mc,new Matrix());
bmpMap=new Bitmap(bmpData);
bmpMap.x=rectCanvas.x;
bmpMap.y=rectCanvas.y;
scene.addChild(bmpMap);
添加开始游戏,再玩一边按钮的事件侦听器
选中开始按钮,查看其属性,并设置器实例名称,然后为该实例名称添加代码,开始按钮的代码如下:
this.btnStart.addEventListener(MouseEvent.CLICK,btnStart_ClickHandler);
同理选择再玩一遍按钮,查看其属性,并且设置实例名称,然后为该实例名称添加代码,再玩一遍按钮的代码如下:
this.btnReplay.addEventListener(MouseEvent.CLICK,btnReplay_ClickHandler);
this.btnPlus.addEventListener(MouseEvent.CLICK,btnPlus_ClickHandler);
this.btnMinus.addEventListener(MouseEvent.CLICK,btnMinus_ClickHandler);
}
private function clearTiles():void{
for(var i:uint=0; i<aTiles.length; i++){
scene.removeChild(aTiles[i]);
}
aTiles=[];
}
private function initArea():void{
lineSprite=new Sprite();
lineSprite.graphics.lineStyle(1,0x000000,.2);
for(var i:uint=0; i<col-1; i++){
lineSprite.graphics.moveTo(rectCanvas.x,rectCanvas.y+tileHeight*(i+1));
lineSprite.graphics.lineTo(rectCanvas.x+rectCanvas.width,rectCanvas.y+tileHeight*(i+1));
lineSprite.graphics.moveTo(rectCanvas.x+tileWidth*(i+1),rectCanvas.y);
lineSprite.graphics.lineTo(rectCanvas.x+tileWidth*(i+1),rectCanvas.y+rectCanvas.height);
}
addChild(lineSprite);
}
初始化拼图碎片
private function initTiles():void{
bmpMap.visible=false;
clearTiles();
for(var i:uint=0; i<col; i++){ flash小游戏制作论文(11):http://www.751com.cn/jisuanji/lunwen_140.html