2011-10-27 174 views
1

我是一个在as3中的益智游戏,我已经完成了。 我将一个位图分成8个部分,我将它们转换为mc,然后用鼠标移动它们。游戏解决方案ActionScript 3

我的拼图板也被拼在一起, 现在我该如何制作拼图解决方案,比如当拼图按正确的顺序排列时,应该显示整个位图。

谢谢您的关注

+0

我有一个IDEEA,但我不知道如何把它放在代码: 我可以分配到每一个MC和每一个电网部分的数字。所以如果mc.1在gridpart.1上等等,比我把mc的不可见,我将整个位图添加到舞台上。 有人有一个ideea我怎样才能使这在as3? 谢谢你的时间 对不起,我的英语不好 – CMS

+0

所以没人能帮到我吗? – CMS

回答

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; 
} 

将位图分割并将它们转换成影片剪辑后,我认为在那个阶段您可以解决这个难题。

如果是,那么您需要在碎片有机会移动之前存储碎片的当前位置。

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

//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... 
} 
+0

我会尝试,但我是AS3的新手,所以我不知道如何制作它 – CMS

+0

我该如何制作游戏的解决方案,我的意思是,当拼图块以正确的顺序排列整个位图时,应该显示图像 – CMS

+0

检查编辑答案,如果这不能回答你的问题,你需要更具体地了解你知道或不知道的内容...... – PatrickS