Added support for setting animation speeds

This commit is contained in:
Collin Smith
2019-11-10 15:21:19 -08:00
parent 29f619fe1b
commit 364775954c
2 changed files with 9 additions and 1 deletions

View File

@ -57,6 +57,8 @@ public class CofComponent implements Component, Pool.Poolable {
Arrays.fill(DEFAULT_ALPHA, ALPHA_NULL);
}
public static final int SPEED_NULL = -1;
public String token;
public int mode;
public int wclass;
@ -64,6 +66,7 @@ public class CofComponent implements Component, Pool.Poolable {
public int dirty; // cof layers need to be loaded
public int load; // cof layers loading
public int update; // update component
public int speed;
public final int component[];
public final byte transform[];
@ -88,6 +91,7 @@ public class CofComponent implements Component, Pool.Poolable {
dirty = Dirty.NONE;
load = Dirty.NONE;
update = Dirty.NONE;
speed = SPEED_NULL;
System.arraycopy(DEFAULT_COMPONENT, 0, component, 0, COF.Component.NUM_COMPONENTS);
System.arraycopy(DEFAULT_TRANSFORM, 0, transform, 0, COF.Component.NUM_COMPONENTS);
System.arraycopy(DEFAULT_ALPHA, 0, alpha, 0, COF.Component.NUM_COMPONENTS);

View File

@ -45,7 +45,11 @@ public class AnimationLoaderSystem extends IteratingSystem {
boolean changed = false;
COF cof = cofComponent.cof;
if (cof == null) return;
anim.setCOF(cof);
// FIXME: logic here needs to be looked into -- should below operations be performed when cof didn't change?
boolean newCof = anim.setCOF(cof);
if (newCof && cofComponent.speed != CofComponent.SPEED_NULL) {
anim.setFrameDelta(cofComponent.speed);
}
for (int l = 0, numLayers = cof.getNumLayers(); l < numLayers; l++) {
COF.Layer layer = cof.getLayer(l);
if (!Dirty.isDirty(cofComponent.load, layer.component)) continue;