如何更改与某个类关联的子影片剪辑的动画,并将其导入数组?
现在,当玩家击中它时,我能够让它消失,用这一行:
this.parent.removeChild(this);
看看它,有2个地雷是用外部进口的。文件并在MineList数组中。
http://teroute.com/stronghold/index.php?page=secret-project
我想让这些地雷在触碰时爆炸。
这里有更多代码:
for (var i:int = 0; i < MineList.length; i++) // Here i count all mines, that are in MineList Array
{
if(player.hitTestObject(MineList[i])) // If player touches any mine
{
MineList[i].removeSelf(); // If player touches a mine,
// then this mine will dissapear
}
}
这里是一个removeSelf函数。外部文件:
public function removeSelf():void
{
trace("Removed");
removeEventListener(Event.ENTER_FRAME, loop) // Sustabdyti loop
this.parent.removeChild(this); // panaikinimas
}
我认为应该改变这一行:
this.parent.removeChild(this);
类似于:
this.parent.gotoAndPlay(2);
但我做错了,请帮忙。
答案 0 :(得分:0)
this.parent.gotoAndPlay(2);
意味着你要告诉闪光灯从我父母的第二帧转到并播放。如果你想从它的第二帧开始玩,那么你应该写下面的东西
this.gotoAndPlay(2);
始终检查范围或您要访问的内容,以确保正确完成任务。