mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +08:00
Minor changes.
This commit is contained in:
parent
d2d6919afb
commit
8bd2171250
@ -65,10 +65,11 @@ public class Animation {
|
|||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public void apply (Skeleton skeleton, float time, boolean loop) {
|
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.
|
/** 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. */
|
* @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) {
|
public void apply (Skeleton skeleton, float lastTime, float time, boolean loop, Array<Event> events) {
|
||||||
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
|
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
|
||||||
@ -85,12 +86,13 @@ public class Animation {
|
|||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public void mix (Skeleton skeleton, float time, boolean loop, float alpha) {
|
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.
|
/** 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 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 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) {
|
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.");
|
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@ public class AnimationState {
|
|||||||
events.clear();
|
events.clear();
|
||||||
|
|
||||||
if (previous != null) {
|
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;
|
float alpha = mixTime / mixDuration;
|
||||||
if (alpha >= 1) {
|
if (alpha >= 1) {
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public class SkeletonTest extends ApplicationAdapter {
|
|||||||
renderer = new SkeletonRenderer();
|
renderer = new SkeletonRenderer();
|
||||||
debugRenderer = new SkeletonRendererDebug();
|
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.
|
// 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);
|
Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
|
||||||
@ -93,7 +93,7 @@ public class SkeletonTest extends ApplicationAdapter {
|
|||||||
// binary.setScale(2);
|
// binary.setScale(2);
|
||||||
skeletonData = binary.readSkeletonData(Gdx.files.internal(name + ".skel"));
|
skeletonData = binary.readSkeletonData(Gdx.files.internal(name + ".skel"));
|
||||||
}
|
}
|
||||||
animation = skeletonData.findAnimation("drawOrder");
|
animation = skeletonData.findAnimation("walk");
|
||||||
|
|
||||||
skeleton = new Skeleton(skeletonData);
|
skeleton = new Skeleton(skeletonData);
|
||||||
if (name.equals("goblins")) skeleton.setSkin("goblin");
|
if (name.equals("goblins")) skeleton.setSkin("goblin");
|
||||||
|
|||||||
@ -48,7 +48,7 @@
|
|||||||
"bounding box": {
|
"bounding box": {
|
||||||
"bbox": {
|
"bbox": {
|
||||||
"type": "boundingbox",
|
"type": "boundingbox",
|
||||||
"points": [
|
"vertices": [
|
||||||
-7.2252045,
|
-7.2252045,
|
||||||
-34.808647,
|
-34.808647,
|
||||||
-1.9847412,
|
-1.9847412,
|
||||||
@ -101,7 +101,7 @@
|
|||||||
"left upper leg": {
|
"left upper leg": {
|
||||||
"boundingbox": {
|
"boundingbox": {
|
||||||
"type": "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": {
|
"right hand item": {
|
||||||
|
|||||||
@ -129,15 +129,15 @@
|
|||||||
"head": {
|
"head": {
|
||||||
"rotate": [
|
"rotate": [
|
||||||
{ "time": 0, "angle": 0 },
|
{ "time": 0, "angle": 0 },
|
||||||
{ "time": 0.4827, "angle": -11.07, "curve": "stepped" },
|
{ "time": 0.4827, "angle": -23.11 },
|
||||||
{ "time": 0.8965, "angle": -11.07 },
|
{ "time": 0.8965, "angle": -56.45 },
|
||||||
{ "time": 1.3103, "angle": 1.38 },
|
{ "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.1379, "angle": 1.24 },
|
||||||
{ "time": 2.6206, "angle": -16.12, "curve": "stepped" },
|
{ "time": 2.6206, "angle": -37.12 },
|
||||||
{ "time": 3.3103, "angle": -16.12 },
|
{ "time": 2.9666, "angle": 2.07 },
|
||||||
{ "time": 3.6551, "angle": 1.31 },
|
{ "time": 3.4666, "angle": 34.72 },
|
||||||
{ "time": 4, "angle": 359.99 }
|
{ "time": 3.9, "angle": 359.99 }
|
||||||
],
|
],
|
||||||
"translate": [
|
"translate": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -129,15 +129,15 @@
|
|||||||
"head": {
|
"head": {
|
||||||
"rotate": [
|
"rotate": [
|
||||||
{ "time": 0, "angle": 0 },
|
{ "time": 0, "angle": 0 },
|
||||||
{ "time": 0.4827, "angle": -11.07, "curve": "stepped" },
|
{ "time": 0.4827, "angle": -23.11 },
|
||||||
{ "time": 0.8965, "angle": -11.07 },
|
{ "time": 0.8965, "angle": -56.45 },
|
||||||
{ "time": 1.3103, "angle": 1.38 },
|
{ "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.1379, "angle": 1.24 },
|
||||||
{ "time": 2.6206, "angle": -16.12, "curve": "stepped" },
|
{ "time": 2.6206, "angle": -37.12 },
|
||||||
{ "time": 3.3103, "angle": -16.12 },
|
{ "time": 2.9666, "angle": 2.07 },
|
||||||
{ "time": 3.6551, "angle": 1.31 },
|
{ "time": 3.4666, "angle": 34.72 },
|
||||||
{ "time": 4, "angle": 359.99 }
|
{ "time": 3.9, "angle": 359.99 }
|
||||||
],
|
],
|
||||||
"translate": [
|
"translate": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -86,16 +86,19 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
state = new AnimationState(stateData);
|
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) {
|
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);
|
state.SetAnimation("drawOrder", true);
|
||||||
} else {
|
} else {
|
||||||
state.SetAnimation("walk", false);
|
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);
|
state.AddAnimation("walk", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,14 +135,13 @@ namespace Spine {
|
|||||||
|
|
||||||
bounds.Update(skeleton);
|
bounds.Update(skeleton);
|
||||||
MouseState mouse = Mouse.GetState();
|
MouseState mouse = Mouse.GetState();
|
||||||
|
headSlot.G = 1;
|
||||||
|
headSlot.B = 1;
|
||||||
if (bounds.AabbContainsPoint(mouse.X, mouse.Y)) {
|
if (bounds.AabbContainsPoint(mouse.X, mouse.Y)) {
|
||||||
BoundingBoxAttachment hit = bounds.ContainsPoint(mouse.X, mouse.Y);
|
BoundingBoxAttachment hit = bounds.ContainsPoint(mouse.X, mouse.Y);
|
||||||
if (hit != null) {
|
if (hit != null) {
|
||||||
headSlot.G = 0;
|
headSlot.G = 0;
|
||||||
headSlot.B = 0;
|
headSlot.B = 0;
|
||||||
} else {
|
|
||||||
headSlot.G = 1;
|
|
||||||
headSlot.B = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,19 +149,19 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Start (object sender, EventArgs e) {
|
public void Start (object sender, EventArgs e) {
|
||||||
Console.WriteLine("start");
|
Console.WriteLine(state + ": start");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void End (object sender, EventArgs e) {
|
public void End (object sender, EventArgs e) {
|
||||||
Console.WriteLine("end");
|
Console.WriteLine(state + ": end");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Complete (object sender, CompleteArgs e) {
|
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) {
|
public void Event (object sender, EventTriggeredArgs e) {
|
||||||
Console.WriteLine("event " + e.Event);
|
Console.WriteLine(state + ": event " + e.Event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user