Search in sources :

Example 11 with Animation

use of com.gemserk.animation4j.gdx.Animation in project commons-gdx by gemserk.

the class AnimationResourceBuilder method build.

@Override
public Animation build() {
    Texture spriteSheet = resourceManager.getResourceValue(spriteSheetId);
    Sprite[] frames = new Sprite[this.frames.size()];
    float[] times = new float[this.frames.size()];
    for (int i = 0; i < frames.length; i++) {
        Frame frame = this.frames.get(i);
        frames[i] = new Sprite(spriteSheet, frame.x, frame.y, frame.w, frame.h);
        // convert time from milliseconds to seconds
        times[i] = (float) frame.time * 0.001f;
    }
    return new Animation(frames, new FrameAnimationImpl(loop, times));
}
Also used : FrameAnimationImpl(com.gemserk.animation4j.FrameAnimationImpl) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Animation(com.gemserk.animation4j.gdx.Animation) Texture(com.badlogic.gdx.graphics.Texture)

Aggregations

Animation (com.gemserk.animation4j.gdx.Animation)11 AnimationFrameMonitor (com.gemserk.animation4j.gdx.AnimationFrameMonitor)8 Test (org.junit.Test)8 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)3 FrameAnimationImpl (com.gemserk.animation4j.FrameAnimationImpl)3 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)2 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)2 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2 Texture (com.badlogic.gdx.graphics.Texture)1 Array (com.badlogic.gdx.utils.Array)1 FloatValue (com.gemserk.commons.values.FloatValue)1 ArrayList (java.util.ArrayList)1