OSDN Git Service

[removed] Forever action. Does not play well with Pools used inside actions to get...
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sat, 23 Oct 2010 22:18:18 +0000 (22:18 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sat, 23 Oct 2010 22:18:18 +0000 (22:18 +0000)
gdx/src/com/badlogic/gdx/scenes/scene2d/actions/Delay.java
gdx/src/com/badlogic/gdx/scenes/scene2d/actions/FadeIn.java
gdx/src/com/badlogic/gdx/scenes/scene2d/actions/Forever.java [deleted file]
gdx/src/com/badlogic/gdx/scenes/scene2d/actions/Parallel.java
gdx/src/com/badlogic/gdx/scenes/scene2d/actions/RotateBy.java
gdx/src/com/badlogic/gdx/scenes/scene2d/actions/Sequence.java
tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java

index b4a5917..b9068bb 100644 (file)
@@ -51,5 +51,4 @@ public class Delay implements Action
                        pool.free( this );\r
                return done;\r
        }\r
-\r
 }\r
index 7336de2..dc0938f 100644 (file)
@@ -62,5 +62,4 @@ public class FadeIn implements Action
        {\r
                return done;\r
        }\r
-\r
 }\r
diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/actions/Forever.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/actions/Forever.java
deleted file mode 100644 (file)
index 68b16a6..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-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
index 4be6f8b..ec7a182 100644 (file)
@@ -21,6 +21,7 @@ public class Parallel implements Action
        public static Parallel $( Action ... actions )\r
        {\r
                Parallel action = pool.newObject();\r
+               action.actions.clear();\r
                int len = actions.length;\r
                for( int i = 0; i < len; i++ )\r
                        action.actions.add( actions[i] );\r
@@ -53,5 +54,4 @@ public class Parallel implements Action
                                return false;\r
                return true;\r
        }\r
-       \r
 }\r
index 4cfc20d..2cf4e15 100644 (file)
@@ -51,7 +51,6 @@ public class RotateBy implements Action
                {\r
                        pool.free( this );\r
                        taken = duration;\r
-                       target.rotation = rotation;\r
                        done = true;\r
                        return;\r
                }\r
index b80cbe2..075ca59 100644 (file)
@@ -25,10 +25,10 @@ public class Sequence implements Action
        public static Sequence $( Action ... actions )\r
        {\r
                Sequence action = pool.newObject();\r
+               action.actions.clear();\r
                int len = actions.length;\r
                for( int i = 0; i < len; i++ )\r
                        action.actions.add( actions[i] );\r
-               action.currAction = 0;\r
                return action;\r
        }\r
        \r
@@ -38,6 +38,7 @@ public class Sequence implements Action
                this.target = actor;\r
                if( actions.size() > 0 )\r
                        actions.get(0).setTarget( target );\r
+               this.currAction = 0;\r
        }\r
 \r
        @Override\r
index 44253b9..7fa447a 100644 (file)
@@ -18,6 +18,7 @@ import com.badlogic.gdx.scenes.scene2d.actions.FadeIn;
 import com.badlogic.gdx.scenes.scene2d.actions.FadeOut;\r
 import com.badlogic.gdx.scenes.scene2d.actions.MoveTo;\r
 import com.badlogic.gdx.scenes.scene2d.actions.Parallel;\r
+import com.badlogic.gdx.scenes.scene2d.actions.RotateBy;\r
 import com.badlogic.gdx.scenes.scene2d.actions.RotateTo;\r
 import com.badlogic.gdx.scenes.scene2d.actions.ScaleTo;\r
 import com.badlogic.gdx.scenes.scene2d.actions.Sequence;\r
@@ -61,9 +62,8 @@ public class UITest implements RenderListener, InputListener
                        \r
                        Image img1 = new Image( "image1", new TextureRegion( badlogic, 0, 0, 256, 256 ) );\r
                        img1.width = img1.height = 64; img1.originX = img1.originY = 32;\r
-                       ui.addActor( img1 );\r
                        img1.action( Sequence.$( \r
-                                                                               FadeOut.$(0),\r
+                                                                               FadeOut.$(1),\r
                                                                                FadeIn.$(1),\r
                                                                                Delay.$( MoveTo.$( 100, 100, 1 ), 2 ),\r
                                                                                ScaleTo.$( 0.5f, 0.5f, 1 ),\r
@@ -76,8 +76,10 @@ public class UITest implements RenderListener, InputListener
                                                                                                , 1 )\r
                                                                        )\r
                                                );\r
+                       ui.addActor( img1 );\r
                        \r
-                       Button button = new Button( "button", atlas.getRegion( "button" ), atlas.getRegion( "buttonDown" ) );                   \r
+                       Button button = new Button( "button", atlas.getRegion( "button" ), atlas.getRegion( "buttonDown" ) );\r
+                       button.action( RotateBy.$( 360, 4 ) );\r
                        ui.addActor( button );\r
                        \r
                        LinearGroup linear = new LinearGroup( "linear", 64, 32 * 3, LinearGroupLayout.Vertical );\r
@@ -85,18 +87,16 @@ public class UITest implements RenderListener, InputListener
                        linear.addActor( new Button( "blend", atlas.getRegion( "blend" ), atlas.getRegion( "blendDown" )  ) );\r
                        linear.addActor( new Button( "scale", atlas.getRegion( "scale" ), atlas.getRegion( "scaleDown" ) ) );\r
                        linear.addActor( new Button( "rotate", atlas.getRegion( "rotate" ), atlas.getRegion( "rotateDown" ) ) );\r
+                       linear.action( Parallel.$( ScaleTo.$( 1, 1, 2 ), RotateTo.$( 720, 2 ) ) );\r
                        ui.addActor( linear );\r
-                       linear.action( Parallel.$( ScaleTo.$( 1, 1, 2 ), RotateTo.$( 720, 2 ) ) );                      \r
-\r
                        \r
                        LinearGroup linearh = new LinearGroup( "linearh", 64 * 3, 32, LinearGroupLayout.Horizontal );\r
                        linearh.x = 500; linearh.y = 10;\r
                        linearh.addActor( new Button( "blendh", atlas.getRegion( "blend" ), atlas.getRegion( "blendDown" )  ) );\r
                        linearh.addActor( new Button( "scaleh", atlas.getRegion( "scale" ), atlas.getRegion( "scaleDown" ) ) );\r
                        linearh.addActor( new Button( "rotateh", atlas.getRegion( "rotate" ), atlas.getRegion( "rotateDown" ) ) );\r
+                       linearh.action( MoveTo.$(100, 10, 1.5f) );\r
                        ui.addActor( linearh );                 \r
-                       linearh.action( MoveTo.$(100, 10, 1.5f) );      \r
-\r
                        \r
 //                     Group.enableDebugging( "data/debug.png" );\r
                }\r
@@ -158,7 +158,7 @@ public class UITest implements RenderListener, InputListener
                                ui.toStageCoordinates( x, y, point );\r
                                actor.clearActions();\r
                                actor.action( MoveTo.$( point.x, point.y, 2 ) );\r
-                               actor.action( RotateTo.$( actor.rotation + 90, 2 ) );\r
+                               actor.action( RotateBy.$( 90, 2 ) );\r
                                if( actor.scaleX == 1.0f )\r
                                        actor.action( ScaleTo.$( 0.5f, 0.5f, 2 ) );\r
                                else\r