动画之间的libGDX延迟

时间:2014-11-05 11:45:55

标签: java android libgdx

    if (Intersector.overlaps(Object.getBoundingCircle(), myWorld.getGround())) {
        batcher.draw(DownpAni.getKeyFrame(runTime), Object.getX(),
                Object.getY(), Object.getWidth(), Object.getHeight());
    }else {
        batcher.draw(JumpAni.getKeyFrame(runTime), Object.getX(),
                Object.getY(), Object.getWidth(), Object.getHeight());
    }

我有一个物体可以保持动画,一个触及地面,另一个离开时。我使用上面的代码确定每个动画何时出现,问题是,我不知道如何在改变之前增加DownAni的时间量? 任何人都可以帮我解决如何延迟动画之间的变化吗?

1 个答案:

答案 0 :(得分:0)

我无法测试它,但如果我明白你想做什么,因为我的英语不是很好,这是一个简单的ejmplo可以改进,但我认为这就是你想要的

// varible class;

float deltaYourExc = -1f;
float deltaYourTime = 5f;

 if  ( Intersector . overlaps ( Object . getBoundingCircle (), myWorld . getGround ()) || (deltaYourExc <= deltaYourTime && deltaYourExc != -1))  { 
        batcher . draw ( DownpAni . getKeyFrame ( runTime ),  Object . getX (), 
                Object . getY (),  Object . getWidth (),  Object . getHeight ()); 

    //delta is delta in render
    deltaYourExc += delta;
    if(deltaYourExc >= deltaYourTime){
    deltaYourExc = -1f
    }

    }else{ 
        batcher . draw ( JumpAni . getKeyFrame ( runTime ),  Object . getX (), 
                Object . getY (),  Object . getWidth (),  Object . getHeight ()); 
    }