games.rednblack.editor.renderer.systems.SpriteAnimationSystem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of runtime-libgdx Show documentation
Show all versions of runtime-libgdx Show documentation
HyperLap2D libGDX runtime to render exported scenes
The newest version!
package games.rednblack.editor.renderer.systems;
import com.artemis.ComponentMapper;
import com.artemis.annotations.All;
import com.artemis.systems.IteratingSystem;
import games.rednblack.editor.renderer.components.TextureRegionComponent;
import games.rednblack.editor.renderer.components.sprite.SpriteAnimationComponent;
import games.rednblack.editor.renderer.components.sprite.SpriteAnimationStateComponent;
@All(SpriteAnimationComponent.class)
public class SpriteAnimationSystem extends IteratingSystem {
protected ComponentMapper tm;
protected ComponentMapper sm;
protected ComponentMapper sa;
@Override
protected void process(int entityId) {
TextureRegionComponent tex = tm.get(entityId);
SpriteAnimationStateComponent state = sm.get(entityId);
state.currentAnimation.setFrameDuration(1f / sa.get(entityId).fps);
tex.region = state.currentAnimation.getKeyFrame(state.time);
if (!state.paused) {
state.time += world.delta;
}
}
}