动画精灵在 AndEngine 中的动画效果不止一次

发布于 2024-12-17 19:13:19 字数 687 浏览 2 评论 0原文

我试图只对精灵进行一次动画处理,但它进行了两次动画处理,有人可以帮助我吗?这是代码

    CuttingLineEffect(float x, float y, TiledTextureRegion line_region)
{
    super(x, y, line_region);
    this.animate(60, 1);
    this.mPhysicsHandler = new PhysicsHandler(this); 
    this.registerUpdateHandler(this.mPhysicsHandler);
    this.setPosition(x-this.getWidth()/2-50+this.getWidth()/2,y+50);
}

@Override
protected void onManagedUpdate(float pSecondsElapsed) {

    if(!set)
    {
        MainMenu.LineList.add(this);
        set = true;
    }
    if(!this.isAnimationRunning() && !time_to_unload)
    {
        time_to_unload = true;

    }


    super.onManagedUpdate(pSecondsElapsed);
};

I was trying to animate a sprite only once but it is animated twice can any one help me with this?? Here is the code

    CuttingLineEffect(float x, float y, TiledTextureRegion line_region)
{
    super(x, y, line_region);
    this.animate(60, 1);
    this.mPhysicsHandler = new PhysicsHandler(this); 
    this.registerUpdateHandler(this.mPhysicsHandler);
    this.setPosition(x-this.getWidth()/2-50+this.getWidth()/2,y+50);
}

@Override
protected void onManagedUpdate(float pSecondsElapsed) {

    if(!set)
    {
        MainMenu.LineList.add(this);
        set = true;
    }
    if(!this.isAnimationRunning() && !time_to_unload)
    {
        time_to_unload = true;

    }


    super.onManagedUpdate(pSecondsElapsed);
};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

偏爱你一生 2024-12-24 19:13:19

Animate() 第二个参数是您想要循环该动画的次数。因为您只想在使用时为其设置动画。

this.animate(60,0);

The Animate() second parameter is how many times you want to loop that animation. because you only want to animate it once you might aswell use.

this.animate(60,0);
好多鱼好多余 2024-12-24 19:13:19
Sprite.animate(100,false);
  • 100 -->每帧的持续时间
  • false -->第二个参数是你想要或不循环。
Sprite.animate(100,false);
  • 100 --> the time duration for each frame
  • false --> the second parameter is either you want to loop or not.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文