public static Parallel $ (Action... actions) {\r
Parallel action = pool.add();\r
action.actions.clear();\r
+ if(action.finished == null || action.finished.length < actions.length) \r
+ action.finished = new boolean[actions.length];\r
int len = actions.length;\r
for (int i = 0; i < len; i++)\r
action.actions.add(actions[i]);\r
}\r
\r
protected final List<Action> actions = new ArrayList<Action>();\r
+ protected boolean[] finished;\r
\r
@Override public void setTarget (Actor actor) {\r
int len = actions.size();\r
\r
@Override public void act (float delta) {\r
int len = actions.size();\r
- for (int i = 0; i < len; i++)\r
- if (!actions.get(i).isDone()) actions.get(i).act(delta);\r
+ for (int i = 0; i < len; i++) {\r
+ if (!actions.get(i).isDone()) {\r
+ actions.get(i).act(delta);\r
+ } else {\r
+ if(!finished[i]) {\r
+ actions.get(i).finish();\r
+ finished[i] = true;\r
+ }\r
+ }\r
+ }\r
}\r
\r
@Override public boolean isDone () {\r
@Override public void finish () {\r
pool.removeValue(this, true);\r
int len = 0;\r
- for (int i = 0; i < len; i++)\r
- actions.get(i).finish();\r
+ for (int i = 0; i < len; i++) {\r
+ if(!finished[i])\r
+ actions.get(i).finish();\r
+ }\r
if(listener != null)\r
listener.completed(this);\r
}\r
Parallel action = pool.add();\r
action.actions.clear();\r
int len = actions.size();\r
+ for(int i = 0; i < len; i++)\r
+ action.finished[i] = false;\r
+ len = actions.size();\r
for (int i = 0; i < len; i++)\r
action.actions.add(actions.get(i).copy());\r
return action;\r
\r
actions.get(currAction).act(delta);\r
if (actions.get(currAction).isDone()) {\r
+ actions.get(currAction).finish();\r
currAction++;\r
if (currAction < actions.size()) actions.get(currAction).setTarget(target);\r
}\r
\r
@Override public void finish () {\r
pool.removeValue(this, true);\r
- int len = 0;\r
- for (int i = 0; i < len; i++)\r
- actions.get(i).finish();\r
+ int len = 0; \r
if(listener != null)\r
listener.completed(this);\r
}\r