Last active
August 29, 2015 14:08
-
-
Save chaosddp/1e4067c252bd14461ed0 to your computer and use it in GitHub Desktop.
Display spritesheet animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Using Statements | |
using Share; | |
using System; | |
using WaveEngine.Common; | |
using WaveEngine.Common.Graphics; | |
using WaveEngine.Common.Math; | |
using WaveEngine.Components.Animation; | |
using WaveEngine.Components.Cameras; | |
using WaveEngine.Components.Graphics2D; | |
using WaveEngine.Components.Graphics3D; | |
using WaveEngine.Framework; | |
using WaveEngine.Framework.Graphics; | |
using WaveEngine.Framework.Resources; | |
using WaveEngine.Framework.Services; | |
#endregion | |
namespace LoadAnimationProject | |
{ | |
public class MyScene : Scene | |
{ | |
protected override void CreateScene() | |
{ | |
// Create a 2D camera | |
var camera2D = new FixedCamera2D("Camera2D") { }; | |
EntityManager.Add(camera2D); | |
// 加载动画文件 | |
var animation = Animation2D.Create<TexturePackerGenericJson>("Content/Animations/running_bot.json"); | |
// 定义一个动画run,从0帧开始,一共10帧,速度是每秒15帧 | |
animation.Add("run", new SpriteSheetAnimationSequence() | |
{ | |
First = 0, | |
Length = 10, | |
FramesPerSecond = 15 | |
}); | |
// Draw a simple sprite | |
Entity sprite = new Entity() | |
.AddComponent(new Transform2D()) | |
.AddComponent(new Sprite("Content/Animations/running_bot")) //使用sprite来加载一整张 | |
.AddComponent(new AnimatedSpriteRenderer()) // 这里要使用动画渲染,否则怎么动 | |
.AddComponent(animation); | |
this.EntityManager.Add(sprite); | |
animation.Play(true); // 奔跑吧,少年 | |
} | |
protected override void Start() | |
{ | |
base.Start(); | |
// This method is called after the CreateScene and Initialize methods and before the first Update. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment