只播放一个关键帧
我希望我能很好地解释这一点。但在我的游戏中,我的子弹影片剪辑有 3 个关键帧。 1 显示其正常状态。 2 将其放大,3 将其从舞台上移除。一共3帧。当子弹击中物体时,我会播放第二帧。然后当第 3 帧出现时,我将其删除。这是我的代码
private function blowUp():void
{
if(dead)
{
gotoAndPlay(2);
if(currentFrame == 3)
{
garbage = true;
}
}
}
我的问题是它转到第 2 帧但从未到达第 3 帧。所以第 3 帧不能对子弹进行垃圾收集。如果我使用 Play() 代替,那么它可以工作,但是 gotoAndPlay
我什至没有尝试从第 3 帧中删除关键帧(它仍然是一个帧)。 (希望它能顺利完成)但事实并非如此。我知道我的问题很愚蠢,所以如果有人可以提供帮助,那就太好了。谢谢
I hope I explain this well. But in my game I have 3 keyframes for my bullet Movieclip. 1 to display its normal state. 2 to show it Blown Up, and 3 to remove it from the stage. A total of 3 frames. When the bullet hits an object, I go to and play the 2nd frame. then when frame 3 hits, I remove it. Here is my code
private function blowUp():void
{
if(dead)
{
gotoAndPlay(2);
if(currentFrame == 3)
{
garbage = true;
}
}
}
My problem is it goes to frame 2 but never reaches frame three. so frame 3 can not garbage collect the bullet. If I use Play() instead then it works, but gotoAndPlay doesnt
I even tried to remove the keyframe from frame 3(it is still a frame). (Hoping it would play through) but it doesn't. I know my problem is dumb, so if anyone can help , that would be great. thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你确定你不是每帧都调用blowUp,所以你一直重置到第2帧吗?
如果是这种情况,也许尝试放置一个布尔值守卫:
Are you sure you are not calling blowUp every frame and so you are resetting to frame 2 all the time ?
If is the case, perhaps, try to put a boolean guard:
您必须添加一个输入框架事件处理程序。尝试跟踪 currentFrame 执行逻辑的位置,看看它是否 == 3。我的猜测是,它将是值 2。另一种选择是从第 3 帧调用函数来进行适当的清理。
You would have to add an enter frame event handler. Try tracing currentFrame where you are doing the logic to see if it is == 3. My guess is that it will be a value of two. The other option would be to call a function from frame 3 to do the appropriate clean up.
请注意 Flash Player 9 中的错误,其中 gotoAndPlay(x) 会播放帧“x”两次。
Watch out for the bug in Flash Player 9, where gotoAndPlay(x) would play frame "x" twice.