com.uwsoft.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 overlap2d-runtime-libgdx Show documentation
Show all versions of overlap2d-runtime-libgdx Show documentation
overlap2d-runtime-libgdx provides functionality to load, manipulate and render scenes generated by Overlap2D.
The newest version!
package com.uwsoft.editor.renderer.systems;
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.uwsoft.editor.renderer.components.TextureRegionComponent;
import com.uwsoft.editor.renderer.components.sprite.SpriteAnimationComponent;
import com.uwsoft.editor.renderer.components.sprite.SpriteAnimationStateComponent;
public class SpriteAnimationSystem extends IteratingSystem {
private ComponentMapper tm;
private ComponentMapper sm;
private ComponentMapper sa;
public SpriteAnimationSystem() {
super(Family.all(SpriteAnimationStateComponent.class).get());
tm = ComponentMapper.getFor(TextureRegionComponent.class);
sm = ComponentMapper.getFor(SpriteAnimationStateComponent.class);
sa = ComponentMapper.getFor(SpriteAnimationComponent.class);
}
@Override
public void processEntity(Entity entity, float deltaTime) {
TextureRegionComponent tex = tm.get(entity);
SpriteAnimationStateComponent state = sm.get(entity);
state.currentAnimation.setFrameDuration(1f/sa.get(entity).fps);
tex.region = state.currentAnimation.getKeyFrame(state.time);
state.time += deltaTime;
}
}