use of com.gemserk.commons.artemis.components.SpatialComponent in project commons-gdx by gemserk.
the class SpriteUpdateSystem method processEntities.
@Override
protected void processEntities() {
RandomAccessMap<Entity, EntityComponents> allTheEntityComponents = factory.entityComponents;
int entitiesSize = allTheEntityComponents.size();
for (int entityIndex = 0; entityIndex < entitiesSize; entityIndex++) {
EntityComponents components = allTheEntityComponents.get(entityIndex);
SpatialComponent spatialComponent = components.spatialComponent;
SpriteComponent spriteComponent = components.spriteComponent;
PreviousStateSpatialComponent previousStateSpatialComponent = components.previousStateSpatialComponent;
Spatial spatial = spatialComponent.getSpatial();
float x = spatial.getX();
float y = spatial.getY();
float angle = spatial.getAngle();
if (previousStateSpatialComponent != null) {
float interpolationAlpha = timeStepProvider.getAlpha();
Spatial previousSpatial = previousStateSpatialComponent.getSpatial();
x = FloatInterpolator.interpolate(previousSpatial.getX(), spatial.getX(), interpolationAlpha);
y = FloatInterpolator.interpolate(previousSpatial.getY(), spatial.getY(), interpolationAlpha);
float angleDiff = (float) AngleUtils.minimumDifference(previousSpatial.getAngle(), spatial.getAngle());
angle = FloatInterpolator.interpolate(spatial.getAngle() - angleDiff, spatial.getAngle(), interpolationAlpha);
}
spriteComponent.update(x, y, spatial.getWidth(), spatial.getHeight(), angle);
}
}
use of com.gemserk.commons.artemis.components.SpatialComponent in project commons-gdx by gemserk.
the class ParticleEmitterSystem method process.
@Override
protected void process(Entity e) {
SpatialComponent spatialComponent = Components.getSpatialComponent(e);
Spatial spatial = spatialComponent.getSpatial();
ParticleEmitterComponent particleEmitterComponent = Components.getParticleEmitterComponent(e);
particleEmitterComponent.particleEmitter.setPosition(spatial.getX(), spatial.getY());
particleEmitterComponent.particleEmitter.update(GlobalTime.getDelta());
}
Aggregations