【问题标题】:Game Solution ActionScript 3游戏解决方案 ActionScript 3
【发布时间】:2011-10-27 19:11:39
【问题描述】:

我正在用 as3 制作一个益智游戏,我已经完成了。 我将一个位图分成 8 个部分,然后将它们转换为 mc,然后我可以用鼠标移动它们。

我还制作了一个拼图板,用于放置拼图。 现在我该如何制作一个拼图解决方案,比如当拼图的顺序正确时,应该显示整个位图。

感谢您的关注

【问题讨论】:

  • 我有一个想法,但我不知道如何将其放入代码中:我可以为每个 mc 和每个网格部分分配一个数字。因此,如果 mc.1 在 gridpart.1 上等等,那么我将 mc 设置为不可见,然后将整个位图添加到舞台上。有谁知道我怎样才能在as3中做到这一点?谢谢你的时间对不起我的英语不好

标签: actionscript-3


【解决方案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...
 }

【讨论】:

  • 我会尝试,但我是 AS3 的新手,所以我不知道如何制作它
  • 如何解决游戏问题,我的意思是当拼图的顺序正确时,应该显示整个位图图像
  • 检查编辑的答案,如果这不能回答您的问题,您需要更具体地说明您知道或不知道的内容...
  • 我用绘图功能制作了网格,并在循环中使用它
  • 我将 mc 的位置存储在这样的数组中:array.push({x:0,y:0}); array.push({x;loader.width,y:loader.height});等等我现在该怎么办?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-02-28
  • 1970-01-01
  • 1970-01-01
  • 2011-12-13
  • 1970-01-01
  • 1970-01-01
  • 2020-08-12
相关资源
最近更新 更多