bmpData=new BitmapData(mc.width,mc.height);
bmpData.draw(mc,new Matrix());
bmpMap.bitmapData.copyPixels(bmpData,new Rectangle(0,0,rectCanvas.width,rectCanvas.height),new Point(0,0));
bmpMap.visible=true;
btnStart.visible=true;
btnReplay.visible=false;
clearTiles();
}
private function btnPlus_ClickHandler(e:MouseEvent):void{
if(col<8){
col++;
}
txtTileNum.text=col+"X"+col;
}
private function btnMinus_ClickHandler(e:MouseEvent):void{
if(col>3){
col--;
}
txtTileNum.text=col+"X"+col;
}
private function dragTile(e:MouseEvent):void{
var tile:Tile=Tile(e.currentTarget);
if(tile.dragable){
scene.setChildIndex(tile,scene.numChildren-1);
tile.startDrag();
}
}
private function stopDragTile(e:MouseEvent):void{
var tile:Tile=Tile(e.currentTarget);
tile.stopDrag();
var targetX:Number=tile.index%col*tileWidth+tileWidth/2+rectCanvas.x;
var targetY:Number=Math.floor(tile.index/col)*tileHeight+tileHeight/2+rectCanvas.y;
var targetPoint:Point=new Point(targetX,targetY);
var mousePoint:Point=new Point(e.stageX,e.stageY);
判断以上两个位置是否足够接近,如果距离小于碎片宽度的一半,表示释放位置正确
if(Point.distance(mousePoint,targetPoint)<tileWidth/2){
if(!tile.dragable){
return;
}
不能继续拖曳 flash小游戏制作论文(13):http://www.751com.cn/jisuanji/lunwen_140.html