游戏解决方案ActionScript 3

时间:2011-10-27 09:10:30

标签: actionscript-3

我是as3中的一款益智游戏,我已经完成了。 我将一个位图分成8个部分,我将它们转换成mc,我可以用鼠标移动它们。

我也制作了一个拼图板,拼图块被扯下来。 现在我该如何制作拼图解决方案,比如当拼图块的顺序正确时,应该显示整个位图。

请你注意

1 个答案:

答案 0 :(得分:1)

为什么不将mcs位置存储在点数组中?

这样,无论在主板上的mcs是什么,都很容易将它们补间回位。

 var positions:Array = [ new Point(mc1.x , mc1.y), .... , new Point(mcn.x , mc1.n), ];

 //assuming that this code is run from 
 // the mcs container and that this container
 // doesn't have any other children
 for( var i:int ; i < this.numChildren ; ++i )
 {
     //provided that the MCs are on 
     //the right order in the Display List
     var mc:MovieClip = this.getChildAt(i) as MovieClip;

     //no tween here but you get the idea...
     mc.x = positions[i].x; 
     mc.y = positions[i].y; 
 }

在拆分位图并将它们转换为MovieClip之后,我认为在那个阶段你可以解决这个难题。

如果是,那么您需要在他们有机会被移动之前存储这些作品的当前位置。

实际上,这意味着在实际存储位置之前不要添加事件监听器。

 //instantiate the Array
 var positions:Array = [];
 for(var i:int ; i < this.numChildren; ++i )
 {
    // add the mcs positions
    var positions[i] = new Point ( this.getChildAt(i).x , this.getChildAt(i).y );

    //you could add your Mouse Event listener here...
 }