An inheritance based action system for libGDX.
To use in your project add the following repositories in your build.gradle. Then this project as a dependency with a specified version.
repositories {
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' }
}
dependency {
implementation 'com.vabrantgames.actionsystem:actionsystem:version'
}
Any class that is to be actioned should implement at least one interface to add functionality.
public class Square implements Movable {
private float x;
private float y;
@Override
public void setX(float x) {
this.x = x;
}
@Override
public void setY(float y) {
this.y = y;
}
@Override
public float getX() {
return x;
}
@Override
public float getY() {
return y;
}
}
Note: Depending on which interfaces are implemented determines what actions can be used. A class that only implements Movable can not be used for actions that reply on Colorable.
Create an ActionManager in a top level class like your screen or main game class.
ActionManager actionManager = new ActionManager();
Then in your render method or wherever you update your objects, update the ActionManager by passing in the delta
time.
actionManager.update(delta);
Note: You can get the delta at Gdx.graphics.getDeltaTime();
Actions can easily be created from static helpers located in the action you are trying to use.
MoveAction action = MoveAction.moxeXBy(square, amount, duration, interpolation);
actionManager.add(action);