【问题标题】:AS3 Flash - toggle animation on KeyPressAS3 Flash - KeyPress 上的切换动画
【发布时间】:2015-02-18 15:39:16
【问题描述】:

当我的游戏角色点击电脑并按下空格键时,动画变为gotoAndStop(2)。到目前为止,这是有效的。

我想要的是,当我再次按下空格键时,它会返回到gotoAndStop(1)

我该怎么做呢?

这是我的代码:

public function turnOn(event:KeyboardEvent)
    {
        if(jon.hitTestObject(computers) && event.keyCode == 32)
        {
            computers.gotoAndStop(2);
        }

    }

【问题讨论】:

    标签: actionscript-3 flash animation


    【解决方案1】:

    查看当前计算机的帧:computers.currentFrame

    您的代码将如下所示:

    if(jon.hitTestObject(computers) && event.keyCode == 32)
    {
        if (computers.currentFrame == 1)
            computers.gotoAndStop(2);
        else if (computers.currentFrame == 2)
            computers.gotoAndStop(1);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-11
      • 1970-01-01
      • 1970-01-01
      • 2012-07-04
      • 1970-01-01
      • 1970-01-01
      • 2012-07-29
      相关资源
      最近更新 更多