From 0812aaa091620f0e8f40220862c5a434c1fb8ba0 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Mon, 18 Mar 2013 15:43:12 +0100 Subject: [PATCH] Cleanup, javadocs. --- spine-libgdx/spine-libgdx.iml | 24 - spine-libgdx/spine-libgdx.ipr | 169 ---- spine-libgdx/spine-libgdx.iws | 823 ------------------ .../spine/AnimationState.java | 22 +- ...tatesTest.java => AnimationStateTest.java} | 11 +- .../com/esotericsoftware/spine/MixTest.java | 1 + 6 files changed, 18 insertions(+), 1032 deletions(-) delete mode 100644 spine-libgdx/spine-libgdx.iml delete mode 100644 spine-libgdx/spine-libgdx.ipr delete mode 100644 spine-libgdx/spine-libgdx.iws rename spine-libgdx/test/com/esotericsoftware/spine/{AnimationStatesTest.java => AnimationStateTest.java} (82%) diff --git a/spine-libgdx/spine-libgdx.iml b/spine-libgdx/spine-libgdx.iml deleted file mode 100644 index 0a96da4fc..000000000 --- a/spine-libgdx/spine-libgdx.iml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spine-libgdx/spine-libgdx.ipr b/spine-libgdx/spine-libgdx.ipr deleted file mode 100644 index 8055423e4..000000000 --- a/spine-libgdx/spine-libgdx.ipr +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spine-libgdx/spine-libgdx.iws b/spine-libgdx/spine-libgdx.iws deleted file mode 100644 index 829444bc1..000000000 --- a/spine-libgdx/spine-libgdx.iws +++ /dev/null @@ -1,823 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Android Lint - - - GSPGrailsGroovy - - - Google Web Toolkit issues - - - GrailsGroovy - - - Groovy - - - J2ME Plugin - - - OSGi - - - Plugin DevKit - - - XPath - - - - - Abstraction issues - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localhost - 5050 - - - - - - - - - 1363316179454 - 1363316179454 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No facets are configured - - - - - - - - jQuery - - - - - - - - 1.7 - - - - - - - - spine-libgdx - - - - - - - - 1.7 - - - - - - - - - - - - - - - - diff --git a/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java b/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java index 3e706e500..07cd2073f 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -1,22 +1,17 @@ package com.esotericsoftware.spine; -import com.esotericsoftware.spine.Animation; -import com.esotericsoftware.spine.Skeleton; - import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.ObjectMap; +/** Stores mixing times between animations and automatically mixes them as animations change. */ public class AnimationState { - Animation current; - float currentTime; - boolean currentLoop; - Animation previous; - float previousTime; - boolean previousLoop; + Animation current, previous; + float currentTime, previousTime; + boolean currentLoop, previousLoop; float mixTime, mixDuration; - Key tempKey = new Key(); - ObjectMap animationToMixTime = new ObjectMap(); + final ObjectMap animationToMixTime = new ObjectMap(); + final Key tempKey = new Key(); public void apply (Skeleton skeleton) { if (current == null) return; @@ -36,6 +31,7 @@ public class AnimationState { mixTime += delta; } + /** Set the mixing duration between two animations. */ public void setMixing (Animation from, Animation to, float duration) { if (from == null) throw new IllegalArgumentException("from cannot be null."); if (to == null) throw new IllegalArgumentException("to cannot be null."); @@ -45,10 +41,13 @@ public class AnimationState { animationToMixTime.put(key, duration); } + /** Set the current animation. */ public void setAnimation (Animation animation, boolean loop) { setAnimation(animation, loop, 0); } + /** Set the current animation. + * @param time The time within the animation to start. */ public void setAnimation (Animation animation, boolean loop, float time) { previous = null; if (animation != null && current != null) { @@ -70,6 +69,7 @@ public class AnimationState { return current; } + /** Returns the time within the current animation. */ public float getTime () { return currentTime; } diff --git a/spine-libgdx/test/com/esotericsoftware/spine/AnimationStatesTest.java b/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java similarity index 82% rename from spine-libgdx/test/com/esotericsoftware/spine/AnimationStatesTest.java rename to spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java index fcfbe67b3..1d1ea8f35 100644 --- a/spine-libgdx/test/com/esotericsoftware/spine/AnimationStatesTest.java +++ b/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java @@ -4,13 +4,12 @@ package com.esotericsoftware.spine; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; -import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; -public class AnimationStatesTest extends ApplicationAdapter { +public class AnimationStateTest extends ApplicationAdapter { SpriteBatch batch; ShapeRenderer renderer; @@ -32,7 +31,9 @@ public class AnimationStatesTest extends ApplicationAdapter { jumpAnimation = json.readAnimation(Gdx.files.internal("spineboy-jump.json"), skeletonData); state = new AnimationState(); + // Define mixing from one animation to another. state.setMixing(walkAnimation, jumpAnimation, 0.4f); + // Set current animation. state.setAnimation(walkAnimation, true); skeleton = new Skeleton(skeletonData); @@ -45,12 +46,13 @@ public class AnimationStatesTest extends ApplicationAdapter { } public void render () { - state.update(Gdx.graphics.getDeltaTime() / 1); //Change the value of the integer to modify animation speed. Increase to slow Speed. + state.update(Gdx.graphics.getDeltaTime()); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); batch.begin(); state.apply(skeleton); + // After one second, change the current animation. Mixing is done by AnimationState for you. if (state.getTime() > 1 && state.getAnimation() == walkAnimation) state.setAnimation(jumpAnimation, false); skeleton.updateWorldTransform(); skeleton.draw(batch); @@ -68,7 +70,6 @@ public class AnimationStatesTest extends ApplicationAdapter { } public static void main (String[] args) throws Exception { - LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); - new LwjglApplication(new AnimationStatesTest()); + new LwjglApplication(new AnimationStateTest()); } } diff --git a/spine-libgdx/test/com/esotericsoftware/spine/MixTest.java b/spine-libgdx/test/com/esotericsoftware/spine/MixTest.java index c63be69cc..6e70dd44a 100644 --- a/spine-libgdx/test/com/esotericsoftware/spine/MixTest.java +++ b/spine-libgdx/test/com/esotericsoftware/spine/MixTest.java @@ -75,6 +75,7 @@ public class MixTest extends ApplicationAdapter { batch.begin(); batch.setColor(Color.GRAY); + // This shows how to manage state manually. See AnimationStatesTest. if (time > total) { // restart time = 0;