for(var j:uint=0; j<col; j++){
var tile:Tile=new Tile(tileWidth,tileHeight);
tile.bmpTile.bitmapData.copyPixels(bmpData,new Rectangle(j*tileWidth,i*tileHeight,tileWidth,tileHeight),new Point(0,0));
tile.index=i*col+j;
拼图碎片可拖曳
tile.dragable=true;
把碎片放置在临时区域
tile.x=rectTemp.x+(rectTemp.width-tileWidth)*Math.random();
tile.y=rectTemp.y+(rectTemp.height-tileHeight)*Math.random();
添加碎片的拖曳事件
tile.addEventListener(MouseEvent.MOUSE_DOWN,dragTile,false);
tile.addEventListener(MouseEvent.MOUSE_UP,stopDragTile,false);
aTiles.push(tile);
scene.addChild(tile);
}
}
}
开始游戏按钮方法
private function btnStart_ClickHandler(e:MouseEvent):void{
tileWidth=rectCanvas.width/col;
tileHeight=rectCanvas.height/col;
totalTiles=col*col;
mc.visible=false;
mcGameInfo.visible=false;
btnStart.visible=false;
显示再玩一边按钮
btnReplay.visible=true;
initArea();
initTiles();
}
再玩一边按钮方法
private function btnReplay_ClickHandler(e:MouseEvent):void{
mc.visible=true;
mcGameInfo.visible=false;
mc.gotoAndStop(Math.ceil(Math.random()*mc.totalFrames));
removeChild(lineSprite);
bmpData=null; flash小游戏制作论文(12):http://www.youerw.com/jisuanji/lunwen_140.html