|
@@ -29,15 +29,9 @@
|
|
|
*****************************************************************************/
|
|
|
|
|
|
using System;
|
|
|
-using System.IO;
|
|
|
-using System.Collections.Generic;
|
|
|
using Microsoft.Xna.Framework;
|
|
|
-using Microsoft.Xna.Framework.Audio;
|
|
|
-using Microsoft.Xna.Framework.Content;
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
-using Microsoft.Xna.Framework.Media;
|
|
|
-using Spine;
|
|
|
|
|
|
namespace Spine {
|
|
|
public class Example : Microsoft.Xna.Framework.Game {
|
|
@@ -50,7 +44,7 @@ namespace Spine {
|
|
|
|
|
|
private string assetsFolder = "data/";
|
|
|
|
|
|
- public Example () {
|
|
|
+ public Example() {
|
|
|
IsMouseVisible = true;
|
|
|
|
|
|
graphics = new GraphicsDeviceManager(this);
|
|
@@ -59,56 +53,51 @@ namespace Spine {
|
|
|
graphics.PreferredBackBufferHeight = 600;
|
|
|
}
|
|
|
|
|
|
- protected override void Initialize () {
|
|
|
- // TODO: Add your initialization logic here
|
|
|
-
|
|
|
- base.Initialize();
|
|
|
- }
|
|
|
-
|
|
|
protected override void LoadContent() {
|
|
|
- // Two color tint effect, comment line 76 to disable
|
|
|
+ // Two color tint effect, comment line 80 to disable
|
|
|
var spineEffect = Content.Load<Effect>("Content\\SpineEffect");
|
|
|
spineEffect.Parameters["World"].SetValue(Matrix.Identity);
|
|
|
spineEffect.Parameters["View"].SetValue(Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up));
|
|
|
|
|
|
skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
|
|
|
- skeletonRenderer.PremultipliedAlpha = true;
|
|
|
+ skeletonRenderer.PremultipliedAlpha = false;
|
|
|
skeletonRenderer.Effect = spineEffect;
|
|
|
|
|
|
- // String name = "spineboy";
|
|
|
- // String name = "goblins-mesh";
|
|
|
- // String name = "raptor";
|
|
|
- // String name = "tank";
|
|
|
- // String name = "coin";
|
|
|
- String name = "TwoColorTest";
|
|
|
- bool binaryData = true;
|
|
|
+ // String name = "spineboy-ess";
|
|
|
+ // String name = "goblins-pro";
|
|
|
+ // String name = "raptor-pro";
|
|
|
+ // String name = "tank-pro";
|
|
|
+ String name = "coin-pro";
|
|
|
+ String atlasName = name.Replace("-pro", "").Replace("-ess", "");
|
|
|
+ bool binaryData = false;
|
|
|
|
|
|
- Atlas atlas = new Atlas(assetsFolder + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
|
|
|
+ Atlas atlas = new Atlas(assetsFolder + atlasName + ".atlas", new XnaTextureLoader(GraphicsDevice));
|
|
|
|
|
|
float scale = 1;
|
|
|
- if (name == "spineboy") scale = 0.6f;
|
|
|
- if (name == "raptor") scale = 0.5f;
|
|
|
- if (name == "tank") scale = 0.3f;
|
|
|
- if (name == "TwoColorTest") scale = 0.5f;
|
|
|
+ if (name == "spineboy-ess") scale = 0.6f;
|
|
|
+ if (name == "raptor-pro") scale = 0.5f;
|
|
|
+ if (name == "tank-pro") scale = 0.3f;
|
|
|
+ if (name == "coin-pro") scale = 1;
|
|
|
|
|
|
SkeletonData skeletonData;
|
|
|
if (binaryData) {
|
|
|
SkeletonBinary binary = new SkeletonBinary(atlas);
|
|
|
binary.Scale = scale;
|
|
|
skeletonData = binary.ReadSkeletonData(assetsFolder + name + ".skel");
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
SkeletonJson json = new SkeletonJson(atlas);
|
|
|
json.Scale = scale;
|
|
|
skeletonData = json.ReadSkeletonData(assetsFolder + name + ".json");
|
|
|
}
|
|
|
skeleton = new Skeleton(skeletonData);
|
|
|
- if (name == "goblins-mesh") skeleton.SetSkin("goblin");
|
|
|
+ if (name == "goblins-pro") skeleton.SetSkin("goblin");
|
|
|
|
|
|
// Define mixing between animations.
|
|
|
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
|
|
state = new AnimationState(stateData);
|
|
|
|
|
|
- if (name == "spineboy") {
|
|
|
+ if (name == "spineboy-ess") {
|
|
|
stateData.SetMix("run", "jump", 0.2f);
|
|
|
stateData.SetMix("jump", "run", 0.4f);
|
|
|
|
|
@@ -123,41 +112,36 @@ namespace Spine {
|
|
|
entry.End += End; // Event handling for queued animations.
|
|
|
state.AddAnimation(0, "run", true, 0);
|
|
|
}
|
|
|
- else if (name == "raptor") {
|
|
|
+ else if (name == "raptor-pro") {
|
|
|
state.SetAnimation(0, "walk", true);
|
|
|
state.AddAnimation(1, "gungrab", false, 2);
|
|
|
}
|
|
|
- else if (name == "coin") {
|
|
|
+ else if (name == "coin-pro") {
|
|
|
state.SetAnimation(0, "rotate", true);
|
|
|
}
|
|
|
- else if (name == "tank") {
|
|
|
+ else if (name == "tank-pro") {
|
|
|
state.SetAnimation(0, "drive", true);
|
|
|
}
|
|
|
- else if (name == "TwoColorTest") {
|
|
|
- state.SetAnimation(0, "animation", true);
|
|
|
- } else {
|
|
|
+ else {
|
|
|
state.SetAnimation(0, "walk", true);
|
|
|
}
|
|
|
|
|
|
- skeleton.X = 400 + (name == "tank" ? 300: 0);
|
|
|
- skeleton.Y = 580 + (name == "TwoColorTest" ? -300 : 0);
|
|
|
+ skeleton.X = 400 + (name == "tank-pro" ? 300 : 0);
|
|
|
+ skeleton.Y = GraphicsDevice.Viewport.Height;
|
|
|
skeleton.UpdateWorldTransform();
|
|
|
|
|
|
headSlot = skeleton.FindSlot("head");
|
|
|
}
|
|
|
|
|
|
- protected override void UnloadContent () {
|
|
|
- }
|
|
|
-
|
|
|
- protected override void Update (GameTime gameTime) {
|
|
|
+ protected override void Update(GameTime gameTime) {
|
|
|
base.Update(gameTime);
|
|
|
}
|
|
|
|
|
|
- protected override void Draw (GameTime gameTime) {
|
|
|
+ protected override void Draw(GameTime gameTime) {
|
|
|
GraphicsDevice.Clear(Color.Black);
|
|
|
|
|
|
state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f);
|
|
|
- state.Apply(skeleton);
|
|
|
+ state.Apply(skeleton);
|
|
|
skeleton.UpdateWorldTransform();
|
|
|
if (skeletonRenderer.Effect is BasicEffect) {
|
|
|
((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1, 0);
|
|
@@ -186,19 +170,19 @@ namespace Spine {
|
|
|
base.Draw(gameTime);
|
|
|
}
|
|
|
|
|
|
- public void Start (TrackEntry entry) {
|
|
|
+ public void Start(TrackEntry entry) {
|
|
|
Console.WriteLine(entry + ": start");
|
|
|
}
|
|
|
|
|
|
- public void End (TrackEntry entry) {
|
|
|
+ public void End(TrackEntry entry) {
|
|
|
Console.WriteLine(entry + ": end");
|
|
|
}
|
|
|
|
|
|
- public void Complete (TrackEntry entry) {
|
|
|
+ public void Complete(TrackEntry entry) {
|
|
|
Console.WriteLine(entry + ": complete ");
|
|
|
}
|
|
|
|
|
|
- public void Event (TrackEntry entry, Event e) {
|
|
|
+ public void Event(TrackEntry entry, Event e) {
|
|
|
Console.WriteLine(entry + ": event " + e);
|
|
|
}
|
|
|
}
|