只播放一个关键帧

发布于 2024-08-18 10:44:40 字数 569 浏览 5 评论 0原文

我希望我能很好地解释这一点。但在我的游戏中,我的子弹影片剪辑有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

毅然前行 2024-08-25 10:44:40

你确定你不是每帧都调用blowUp,所以你一直重置到第2帧吗?

如果是这种情况,也许尝试放置一个布尔值守卫:

    private var doingBlowUp : Boolean = false;

    private function blowUp() : void
    {
        if (dead) {
            if (doingBlowUp)
            {
                if (currentFrame == 3)
                {
                    garbage = true;
                    doingBlowUp = false;
                }

            } else {
                doingBlowUp = true;
                gotoAndPlay(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:

    private var doingBlowUp : Boolean = false;

    private function blowUp() : void
    {
        if (dead) {
            if (doingBlowUp)
            {
                if (currentFrame == 3)
                {
                    garbage = true;
                    doingBlowUp = false;
                }

            } else {
                doingBlowUp = true;
                gotoAndPlay(2);
            }
        }

    }
雨落星ぅ辰 2024-08-25 10:44:40

您必须添加一个输入框架事件处理程序。尝试跟踪 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.

权谋诡计 2024-08-25 10:44:40

请注意 Flash Player 9 中的错误,其中 gotoAndPlay(x) 会播放帧“x”两次。

Watch out for the bug in Flash Player 9, where gotoAndPlay(x) would play frame "x" twice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文