Minor changes.

This commit is contained in:
NathanSweet 2013-09-23 11:21:44 +02:00
parent d2d6919afb
commit 8bd2171250
7 changed files with 39 additions and 35 deletions

View File

@ -65,10 +65,11 @@ public class Animation {
/** @deprecated */
public void apply (Skeleton skeleton, float time, boolean loop) {
apply(skeleton, Float.MAX_VALUE, time, loop, null);
apply(skeleton, time, time, loop, null);
}
/** Poses the skeleton at the specified time for this animation.
* @param lastTime The last time the animation was applied. Can be equal to time if events shouldn't be fired.
* @param events Any triggered events are added. May be null if lastTime is known to not cause any events to trigger. */
public void apply (Skeleton skeleton, float lastTime, float time, boolean loop, Array<Event> events) {
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
@ -85,12 +86,13 @@ public class Animation {
/** @deprecated */
public void mix (Skeleton skeleton, float time, boolean loop, float alpha) {
mix(skeleton, Float.MAX_VALUE, time, loop, null, alpha);
mix(skeleton, time, time, loop, null, alpha);
}
/** Poses the skeleton at the specified time for this animation mixed with the current pose.
* @param alpha The amount of this animation that affects the current pose.
* @param events Any triggered events are added. May be null if lastTime is known to not cause any events to trigger. */
* @param lastTime The last time the animation was applied. Can be equal to time if events shouldn't be fired.
* @param events Any triggered events are added. May be null if lastTime is known to not cause any events to trigger.
* @param alpha The amount of this animation that affects the current pose. */
public void mix (Skeleton skeleton, float lastTime, float time, boolean loop, Array<Event> events, float alpha) {
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");

View File

@ -86,7 +86,7 @@ public class AnimationState {
events.clear();
if (previous != null) {
previous.apply(skeleton, Float.MAX_VALUE, previousTime, previousLoop, null);
previous.apply(skeleton, Integer.MAX_VALUE, previousTime, previousLoop, null);
float alpha = mixTime / mixDuration;
if (alpha >= 1) {
alpha = 1;

View File

@ -65,7 +65,7 @@ public class SkeletonTest extends ApplicationAdapter {
renderer = new SkeletonRenderer();
debugRenderer = new SkeletonRendererDebug();
final String name = "spineboy"; // "spineboy";
final String name = "goblins"; // "spineboy";
// A regular texture atlas would normally usually be used. This returns a white image for images not found in the atlas.
Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
@ -93,7 +93,7 @@ public class SkeletonTest extends ApplicationAdapter {
// binary.setScale(2);
skeletonData = binary.readSkeletonData(Gdx.files.internal(name + ".skel"));
}
animation = skeletonData.findAnimation("drawOrder");
animation = skeletonData.findAnimation("walk");
skeleton = new Skeleton(skeletonData);
if (name.equals("goblins")) skeleton.setSkin("goblin");

View File

@ -48,7 +48,7 @@
"bounding box": {
"bbox": {
"type": "boundingbox",
"points": [
"vertices": [
-7.2252045,
-34.808647,
-1.9847412,
@ -101,7 +101,7 @@
"left upper leg": {
"boundingbox": {
"type": "boundingbox",
"points": [ -73.94766, 8.514406, -49.917465, 25.294191, -79.28125, 46.664314, -95.755325, 34.604897, -74.9664, 27.453112 ]
"vertices": [ -73.94766, 8.514406, -49.917465, 25.294191, -79.28125, 46.664314, -95.755325, 34.604897, -74.9664, 27.453112 ]
}
},
"right hand item": {

View File

@ -129,15 +129,15 @@
"head": {
"rotate": [
{ "time": 0, "angle": 0 },
{ "time": 0.4827, "angle": -11.07, "curve": "stepped" },
{ "time": 0.8965, "angle": -11.07 },
{ "time": 0.4827, "angle": -23.11 },
{ "time": 0.8965, "angle": -56.45 },
{ "time": 1.3103, "angle": 1.38 },
{ "time": 1.7931, "angle": 12.91 },
{ "time": 1.7931, "angle": 36.12 },
{ "time": 2.1379, "angle": 1.24 },
{ "time": 2.6206, "angle": -16.12, "curve": "stepped" },
{ "time": 3.3103, "angle": -16.12 },
{ "time": 3.6551, "angle": 1.31 },
{ "time": 4, "angle": 359.99 }
{ "time": 2.6206, "angle": -37.12 },
{ "time": 2.9666, "angle": 2.07 },
{ "time": 3.4666, "angle": 34.72 },
{ "time": 3.9, "angle": 359.99 }
],
"translate": [
{

View File

@ -129,15 +129,15 @@
"head": {
"rotate": [
{ "time": 0, "angle": 0 },
{ "time": 0.4827, "angle": -11.07, "curve": "stepped" },
{ "time": 0.8965, "angle": -11.07 },
{ "time": 0.4827, "angle": -23.11 },
{ "time": 0.8965, "angle": -56.45 },
{ "time": 1.3103, "angle": 1.38 },
{ "time": 1.7931, "angle": 12.91 },
{ "time": 1.7931, "angle": 36.12 },
{ "time": 2.1379, "angle": 1.24 },
{ "time": 2.6206, "angle": -16.12, "curve": "stepped" },
{ "time": 3.3103, "angle": -16.12 },
{ "time": 3.6551, "angle": 1.31 },
{ "time": 4, "angle": 359.99 }
{ "time": 2.6206, "angle": -37.12 },
{ "time": 2.9666, "angle": 2.07 },
{ "time": 3.4666, "angle": 34.72 },
{ "time": 3.9, "angle": 359.99 }
],
"translate": [
{

View File

@ -86,16 +86,19 @@ namespace Spine {
}
state = new AnimationState(stateData);
state.Start += new EventHandler(Start);
state.End += new EventHandler(End);
state.Complete += new EventHandler<CompleteArgs>(Complete);
state.Event += new EventHandler<EventTriggeredArgs>(Event);
if (true) {
// Event handling for all animations.
state.Start += new EventHandler(Start);
state.End += new EventHandler(End);
state.Complete += new EventHandler<CompleteArgs>(Complete);
state.Event += new EventHandler<EventTriggeredArgs>(Event);
state.SetAnimation("drawOrder", true);
} else {
state.SetAnimation("walk", false);
state.AddAnimation("jump", false);
QueueEntry entry = state.AddAnimation("jump", false);
entry.End += new EventHandler(End); // Event handling for queued animations.
state.AddAnimation("walk", true);
}
@ -132,14 +135,13 @@ namespace Spine {
bounds.Update(skeleton);
MouseState mouse = Mouse.GetState();
headSlot.G = 1;
headSlot.B = 1;
if (bounds.AabbContainsPoint(mouse.X, mouse.Y)) {
BoundingBoxAttachment hit = bounds.ContainsPoint(mouse.X, mouse.Y);
if (hit != null) {
headSlot.G = 0;
headSlot.B = 0;
} else {
headSlot.G = 1;
headSlot.B = 1;
}
}
@ -147,19 +149,19 @@ namespace Spine {
}
public void Start (object sender, EventArgs e) {
Console.WriteLine("start");
Console.WriteLine(state + ": start");
}
public void End (object sender, EventArgs e) {
Console.WriteLine("end");
Console.WriteLine(state + ": end");
}
public void Complete (object sender, CompleteArgs e) {
Console.WriteLine("complete " + e.LoopCount);
Console.WriteLine(state + ": complete " + e.LoopCount);
}
public void Event (object sender, EventTriggeredArgs e) {
Console.WriteLine("event " + e.Event);
Console.WriteLine(state + ": event " + e.Event);
}
}
}