[changed] All actions to be useable with forever. This means reseting done/taken in setTarget.
public static Delay $( Action action, float duration )\r
{\r
Delay delay = pool.newObject();\r
- delay.taken = 0;\r
delay.duration = duration;\r
delay.action = action;\r
return delay;\r
public void setTarget(Actor actor) \r
{\r
action.setTarget( actor );\r
+ this.taken = 0;\r
}\r
\r
@Override\r
FadeIn action = pool.newObject();\r
action.duration = duration;\r
action.invDuration = 1 / duration;\r
- action.taken = 0;\r
- action.done = false;\r
return action;\r
}\r
\r
this.target.color.a = 0;\r
this.startAlpha = 0;\r
this.deltaAlpha = 1;\r
+ this.taken = 0;\r
+ this.done = false;\r
}\r
\r
@Override\r
FadeOut action = pool.newObject();\r
action.duration = duration;\r
action.invDuration = 1 / duration;\r
- action.taken = 0;\r
- action.done = false;\r
return action;\r
}\r
\r
this.target.color.a = 1;\r
this.startAlpha = 1;\r
this.deltaAlpha = -1;\r
+ this.taken = 0;\r
+ this.done = false;\r
}\r
\r
@Override\r
--- /dev/null
+package com.badlogic.gdx.scenes.scene2d.actions;\r
+\r
+import com.badlogic.gdx.scenes.scene2d.Action;\r
+import com.badlogic.gdx.scenes.scene2d.Actor;\r
+import com.badlogic.gdx.utils.Pool;\r
+import com.badlogic.gdx.utils.Pool.PoolObjectFactory;\r
+\r
+public class Forever implements Action \r
+{\r
+ static final Pool<Forever> pool = new Pool<Forever>( new PoolObjectFactory<Forever>() {\r
+ @Override\r
+ public Forever createObject() \r
+ {\r
+ return new Forever( );\r
+ }\r
+ }, 100 );\r
+ \r
+ private Action action;\r
+ private Actor target;\r
+ \r
+ public static Forever $( Action action )\r
+ {\r
+ Forever forever = pool.newObject();\r
+ forever.action = action;\r
+ return forever;\r
+ }\r
+\r
+ @Override\r
+ public void setTarget(Actor actor) \r
+ {\r
+ this.target = actor;\r
+ action.setTarget( actor );\r
+ }\r
+\r
+ @Override\r
+ public void act(float delta) \r
+ {\r
+ action.act( delta );\r
+ if( action.isDone() )\r
+ action.setTarget( target );\r
+ \r
+ }\r
+\r
+ @Override\r
+ public boolean isDone() {\r
+ return false;\r
+ }\r
+}\r
action.y = y;\r
action.duration = duration;\r
action.invDuration = 1 / duration;\r
- action.taken = 0;\r
- action.done = false;\r
return action;\r
}\r
\r
this.startY = target.y;\r
this.deltaX = x - target.x;\r
this.deltaY = y - target.y;\r
+ this.taken = 0;\r
+ this.done = false;\r
}\r
\r
@Override\r
action.rotation = rotation;\r
action.duration = duration;\r
action.invDuration = 1 / duration;\r
- action.taken = 0;\r
- action.done = false;\r
return action;\r
}\r
\r
this.target = actor;\r
this.startRotation = target.rotation;\r
this.deltaRotation = rotation - target.rotation;\r
+ this.taken = 0;\r
+ this.done = false;\r
}\r
\r
@Override\r
action.scaleY = scaleY;\r
action.duration = duration;\r
action.invDuration = 1 / duration;\r
- action.taken = 0;\r
- action.done = false;\r
return action;\r
}\r
\r
this.deltaScaleX= scaleX - target.scaleX;\r
this.startScaleY = target.scaleY;\r
this.deltaScaleY= scaleY - target.scaleY;\r
+ this.taken = 0;\r
+ this.done = false;\r
}\r
\r
@Override\r