本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Sprite.AddAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.AddAnimation方法的具体用法?C# Sprite.AddAnimation怎么用?C# Sprite.AddAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.Sprite
的用法示例。
在下文中一共展示了Sprite.AddAnimation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadSprite
static Sprite LoadSprite(Game game, string type, int id)
{
string spritePath = string.Format(SpritePathFormat, type, id.ToString("D2"));
var sprite = new Sprite(game.Content.Load<Texture2D>(spritePath), new Point(16, 16));
sprite.AddAnimation("stand", new[] { 6, 7, 8 }, TimeSpan.FromMilliseconds(300), true);
sprite.AddAnimation("run", new[] { 0, 1, 2, 1 }, TimeSpan.FromMilliseconds(100), true);
sprite.AddAnimation("hug", new[] { 9, 10, 11 }, TimeSpan.FromMilliseconds(200), false);
sprite.CurrentAnimation = "stand";
return sprite;
}
示例2: PhysicsEntity
public PhysicsEntity(Game game, string texturePath)
: this()
{
if (texturePath != null)
{
Sprite = new Sprite(game.Content.Load<Texture2D>(texturePath), 1, 1);
Sprite.AddAnimation( "default", 0, 1, TimeSpan.FromSeconds(1));
Sprite.Origin = new Vector2(Sprite.FrameSize.X, Sprite.FrameSize.Y) / 2;
Sprite.CurrentAnimation = "default";
}
}
示例3: CreateZombies
void CreateZombies()
{
var cZombie = new[] { "npc-zombie-01", "npc-zombie-02", "npc-zombie-03", "npc-zombie-04", "player-zombie" };
var cNormal = new[] { "npc-normal-01", "npc-normal-02", "npc-normal-03", "npc-normal-04", "player-normal" };
var classes = new[] { cZombie, cNormal };
var zombieX = Viewport.Width / 4 - 80 * _gui.Scale.X;
foreach (var c in classes)
{
float zombieY = (int)textBasePosY;
float spaceY = (textPosY - textBasePosY) / cZombie.Length - 64 * _gui.Scale.Y;
foreach (var sprite in c)
{
var texture = Game.Content.Load<Texture2D>("Images/Sprites/" + sprite);
var s = new Sprite(texture, new Point(16, 16));
s.AddAnimation("dance", new int[] { 0, 1, 2, 3, 4, 5 }, TimeSpan.FromMilliseconds(200));
var comp = new SpriteComponent(s)
{
Position = new Point((int)zombieX, (int)zombieY),
Scale = new Vector2(4)
};
_gui.Add(comp);
zombieY += 64 * _gui.Scale.Y + spaceY;
}
zombieX += 80;
}
}
示例4: LoadSprite
static Sprite LoadSprite(Game game, string path)
{
var texture = game.Content.Load<Texture2D>(path);
var sprite = new Sprite(texture, 1, 1)
{
Origin = new Vector2(texture.Width / 2, texture.Height / 2)
};
sprite.AddAnimation("default", new[] { 0 }, TimeSpan.FromSeconds(1), true);
return sprite;
}