多次执行相同功能后,逐帧播放MovieClip [英] Play MovieClip frame by frame in addition after same function is executed several times

查看:124
本文介绍了多次执行相同功能后,逐帧播放MovieClip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为fail_mc的MovieClip,它由3个足球组成,在我的游戏中,每当我的玩家失败时,我都需要在1个球上添加X标记,我还有一个hitTestObject来检测球何时击中球门区域,但是当球走到外面时,我需要在failure_mc内打一帧并将X标记添加到球上(我在failure_mc内有3个不同的png文件,每帧上有1个),这是我正在使用的代码,但我不这样做不知道如何逐帧播放failure_mc(请记住,每次都会使用相同的功能,这就是为什么必须将每帧都添加到最后播放的帧中的原因:

I have a MovieClip named fails_mc, it consists of 3 soccer balls and in my game every time my player fails I need to add an X mark over 1 ball, I have a hitTestObject detecting when the ball hits the goal area, but when the ball goes outside I need to play 1 frame inside the fails_mc and add the X mark to a ball ( I have 3 different png files inside fails_mc, 1 on each frame), this is the code I’m using but I don’t know how to play frame by frame the fails_mc (keep in mind that the same function will be used every time, that’s why each frame must be added to the last played frame:

if (ball.hitTestObject(goalie))
{
    goal_mc.play();
    net_mc.play();
}
else
{
    fails_mc.play(+=1); // This is not working

    trace("It’s a fail");
}

3次失败后,我必须触发另一个可以完成游戏的功能,但是稍后我将弄清楚该怎么做.

After 3 fails I must trigger another function that will finish the game but I will figure out how to do that later on.

推荐答案

我认为您所寻找的只是movieClip的nextFrame()函数.

I think all your looking for is the nextFrame() function of a movieClip.

您还可以使用gotoAndStop("x1")-其中"x1"是您希望movieClip转到的帧标签(如果没有引号,则为数字).您可以使用变量来跟踪当前状态.

you could also use gotoAndStop("x1") - where "x1" is the frame label (or number if not in quotes) you want the movieClip to goto. You could use a variable to track the current state.

var misses:int = 0;

if (ball.hitTestObject(goalie))
{

    goal_mc.play();
    net_mc.play();

}
else
{
    misses++;
    trace("It’s a fail");

    if(misses > 3){
        //do your game over stuff
    }else{
        fails_mc.gotoAndStop(misses)
    }
}

这篇关于多次执行相同功能后,逐帧播放MovieClip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆