本文整理汇总了C#中Sprite.SetTextureOffset方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.SetTextureOffset方法的具体用法?C# Sprite.SetTextureOffset怎么用?C# Sprite.SetTextureOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.SetTextureOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static Node Create(Vector3 pos)
{
var cmp = new MyBigExplosion ();
var spr = new Sprite (256, 128);
//spr.AddTexture (Resource.GetTexture ("media/BigExplosion.png"));
spr.AddTexture (new Texture ("./media/BigExplosion.png"));
spr.SetTextureOffset (0, 0);
spr.SetOffset (-128, -64);
var track = new AnimationTrack ("TextureOffset", InterpolationType.Step);
track.AddKeyframe (0, new Vector2 (0, 0));
track.AddKeyframe (200, new Vector2 (256, 0));
track.AddKeyframe (400, new Vector2 (512, 0));
track.AddKeyframe (600, new Vector2 (0, 128));
track.AddKeyframe (800, new Vector2 (256, 128));
track.AddKeyframe (1000, new Vector2 (512, 128));
track.AddKeyframe (1200, new Vector2 (0, 256));
track.AddKeyframe (1400, new Vector2 (256, 256));
track.AddKeyframe (1600, new Vector2 (512, 256));
track.AddKeyframe (1800, new Vector2 (0, 384));
track.AddKeyframe (2000, new Vector2 (256, 384));
track.AddKeyframe (2200, new Vector2 (512, 384));
cmp.clip = new AnimationClip (2400, "Fire-Animation");
cmp.clip.AddTrack (spr, track);
var node = new Node ();
node.Attach (cmp);
node.Attach (spr);
node.Translation = pos;
return node;
}
示例2: Create
public static Node Create(Vector3 pos)
{
var cmp = new MyExplosion ();
var spr = new Sprite (100, 100);
spr.AddTexture (new Texture("media/FireExplosion.png"));
spr.SetTextureOffset (0, 0);
spr.SetOffset (-50, -50);
var track = new AnimationTrack ("TextureOffset", InterpolationType.Step);
track.AddKeyframe (0, new Vector2 (0, 0));
track.AddKeyframe (100, new Vector2 (100 , 0));
track.AddKeyframe (200, new Vector2 (200 , 0));
track.AddKeyframe (300, new Vector2 (300 , 0));
track.AddKeyframe (400, new Vector2 (400 , 0));
track.AddKeyframe (500, new Vector2 (500 , 0));
track.AddKeyframe (600, new Vector2 (600 , 0));
track.AddKeyframe (700, new Vector2 (700 , 0));
track.AddKeyframe (800, new Vector2 (800 , 0));
track.AddKeyframe (900, new Vector2 (900 , 0));
track.AddKeyframe (1000, new Vector2 (0, 100));
track.AddKeyframe (1100, new Vector2 (100, 100));
track.AddKeyframe (1200, new Vector2 (200, 100));
track.AddKeyframe (1300, new Vector2 (300, 100));
track.AddKeyframe (1400, new Vector2 (400, 100));
track.AddKeyframe (1500, new Vector2 (500, 100));
track.AddKeyframe (1600, new Vector2 (600, 100));
track.AddKeyframe (1700, new Vector2 (700, 100));
track.AddKeyframe (1800, new Vector2 (800, 100));
track.AddKeyframe (1900, new Vector2 (900, 100));
track.AddKeyframe (2000, new Vector2 (0, 200));
track.AddKeyframe (2100, new Vector2 (100, 200));
track.AddKeyframe (2200, new Vector2 (200, 200));
track.AddKeyframe (2300, new Vector2 (300, 200));
track.AddKeyframe (2400, new Vector2 (400, 200));
track.AddKeyframe (2500, new Vector2 (500, 200));
track.AddKeyframe (2600, new Vector2 (600, 200));
track.AddKeyframe (2700, new Vector2 (700, 200));
track.AddKeyframe (2800, new Vector2 (800, 200));
track.AddKeyframe (2900, new Vector2 (900, 200));
cmp.clip = new AnimationClip (3000, "Fire-Animation");
cmp.clip.AddTrack (spr, track);
var node = new Node ();
node.Attach (cmp);
node.Attach (spr);
node.DrawPriority = -3;
node.Translation = pos;
return node;
}
示例3: Test_SetTextureOffset
public void Test_SetTextureOffset()
{
var spr = new Sprite (64, 64);
spr.TextureOffset = new Vector2 (1, 2);
Assert.AreEqual (1, spr.TextureOffset.X);
Assert.AreEqual (2, spr.TextureOffset.Y);
spr.SetTextureOffset (3, 4);
Assert.AreEqual (3, spr.TextureOffset.X);
Assert.AreEqual (4, spr.TextureOffset.Y);
}