将精灵设置为当前动画纹理

时间:2015-10-05 13:57:29

标签: animation libgdx box2d

在我的游戏中,我有一些box2d正文,我在render()方法中使用以下代码添加精灵。

for (Body body : worldBodies) {
        if (body.getUserData() instanceof Sprite) {
            Sprite sprite = (Sprite) body.getUserData();

            Vector2 position = body.getPosition();
            sprite.setPosition(position.x - sprite.getWidth() / 2 , position.y - sprite.getHeight() / 2);
            sprite.setRotation(body.getAngle() * MathUtils.radiansToDegrees);
            sprite.draw(batch);
        }
    }

其中一具尸体必须动画。

birdAnimation = new Animation(1, birdAtlas.getRegions());
birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);

这是动画,现在我尝试将主体的精灵obstacle6设置为动画的当前textureRegion,并取消此代码:

obstacle6.setRegion(birdAnimation.getKeyFrame(delta));

不知何故,它只显示了地图集的第一个纹理。我怎样才能改变它?或者还有另一种方法来动画box2d的身体吗? 如果您需要任何其他信息,请发表评论。

1 个答案:

答案 0 :(得分:2)

<?php $url = "http://user:password@owncloud.local/remote.php/webdav/test.mp4"; $localfile = "test.mp4"; $fp = fopen ($localfile, "r"); $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_PUT, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_INFILE, $fp); curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile)); $http_result = curl_exec($ch); $error = curl_error($ch); $http_code = curl_getinfo($ch ,CURLINFO_HTTP_CODE); curl_close($ch); fclose($fp); print $http_code; print "<br /><br />$http_result"; if ($error) { print "<br /><br />$error"; } ?> 方法需要经过的时间,而不是增量时间。