本文整理汇总了C#中Sprite.SetOffset方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.SetOffset方法的具体用法?C# Sprite.SetOffset怎么用?C# Sprite.SetOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.SetOffset方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static Node Create(Vector3 pos, float angle)
{
var cmp = new MyBox ();
var width = 64;
var height = 64;
var depth = 64;
var spr = new Sprite (width, height);
spr.AddTexture (new Texture("media/Box-64x64.png"));
spr.SetOffset (-width / 2, -height / 2);
var body = new RigidBody ();
body.AddShape( new BoxShape (width / 2, height / 2, depth / 2));
body.Material = new PhysicsMaterial ();
body.Material.Restitution = 1.0f;
//body.UseCCD = true;
var node = new Node ("Block");
node.Attach (cmp);
node.Attach (spr);
node.Attach (body);
node.Translation = pos;
node.Rotation = new Quaternion (angle, 0, 0, 1);
return node;
}
示例2: Create
/// <summary>
///
/// </summary>
/// <param name="pos"></param>
/// <param name="groupID"></param>
/// <returns></returns>
public static Node Create(Vector3 pos, int groupID)
{
var cmp = new MyCharacter ();
var spr = new Sprite (64, 64);
spr.AddTexture (Resource.GetDefaultTexture ());
spr.Color = Color.Red;
spr.SetOffset (-32, -32);
var col = new CollisionObject ();
col.Shape = new BoxShape (spr.Width / 2, spr.Height / 2, 1);
//col.SetOffset (spr.Width / 2, spr.Height / 2, 1);
var label = new Label ();
label.Text = "ID = 0x" + groupID.ToString ("x");
label.SetOffset (-spr.Width / 2, -spr.Height / 2);
var node = new Node ("MyCharacter");
node.Attach (cmp);
node.Attach (spr);
node.Attach (col);
node.Attach (label);
node.Translation = pos;
node.GroupID = groupID;
return node;
}
示例3: Create
public static Node Create(Vector3 size, Vector3 pos, float angle)
{
var width = (int)size.X;
var height = (int)size.Y;
var depth = (int)size.Z;
var cmp = new MyWall ();
var spr = new Sprite (width, height);
spr.SetOffset (-width / 2, -height / 2);
spr.Color = Color.White;
var body = new RigidBody ();
body.Mass = 0;
body.Material = new PhysicsMaterial ();
body.Material.Restitution = 1;
body.Use2D = true;
body.AddShape (new BoxShape (width / 2, height / 2, depth/2));
var node = new Node ("Wall");
node.Attach (cmp);
node.Attach (spr);
node.Attach (body);
node.Translation = pos;
node.Rotate (angle, 0, 0, 1);
return node;
}
示例4: 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;
}
示例5: Create
public static Node Create(int slot, Node charNode, Node tankNode)
{
var cha = charNode.GetComponent<MyCharacter> ();
var tank = tankNode.GetComponent<MyTank> ();
var cmp = new MyCard ();
cmp.tank = tankNode;
cmp.character = charNode;
// 背景
var spr1 = new Sprite (256, 128);
spr1.Color = Color.Gray;
// 顔
var spr2 = new Sprite (128, 128);
spr2.AddTexture (cha.FaceTexture);
// 戦車
var spr3 = new Sprite (32, 64);
spr3.AddTexture (tank.TankTexture);
spr3.SetOffset (128 + 6, 6);
// 戦車名
var label1 = new Label ();
label1.Text = tank.TankName;
label1.SetOffset (128 + 6 + 32 + 6, 6);
// HP
var hp = new Bar (4, 96, BarOrientation.Horizontal);
hp.MaxValue = tank.MaxHp;
hp.CurrentValue = tank.Hp;
hp.SetOffset (128 + 6, 64 + 6);
// クリック
var col = new BoxCollision (128, 64, 0);
col.SetOffset (128, 64, 0);
var node = new Node ("Card");
node.Attach (cmp);
node.Attach (spr1);
node.Attach (spr2);
node.Attach (spr3);
node.Attach (label1);
node.Attach (hp);
node.Attach (col);
node.DrawPriority = -10;
node.Translate (12+(256+4)*slot, 600, 0);
// キャラクター -> マイカード
cha.MyCard = node;
return node;
}
示例6: 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;
}
示例7: Create
public static Node Create(Vector3 pos)
{
var cmp = new MyContinuousTrack ();
var spr = new Sprite (40, 20);
spr.AddTexture (Resource.GetTexture ("media/ContinuousTrack.png"));
spr.SetOffset (-20, -20);
var node = new Node ("ContinuousTrack");
node.Attach (cmp);
node.Attach (spr);
node.DrawPriority = -1;
node.Translation = pos;
return node;
}
示例8: Create
public static Node Create(Vector3 pos, MyDirection dir)
{
var cmp = new MyMarker ();
cmp.Direction = dir;
var spr = new Sprite (128, 128);
spr.AddTexture (new Texture ("media/MedicalIconLight.png"));
spr.SetOffset (-64, -128);
var node = new Node ("Marker");
node.Attach (cmp);
node.Attach (spr);
node.DrawPriority = -1;
node.Translation = pos;
return node;
}
示例9: Create
public static Node Create()
{
var cmp = new MyTullet ();
var spr = new Sprite (40, 72);
spr.SetOffset (-20, -52);
var col = new SphereCollision (cmp.effectiveRange);
//col.DrawEnabled = true;
var node = new Node ("Tullet");
node.Attach (cmp);
node.Attach (spr);
node.Attach (col);
node.DrawPriority = -2;
node.Translate (0, -8, 0);
return node;
}
示例10: Create
public static Node Create(Vector3 pos, Quaternion rot)
{
var cmp = new MyProjectile ();
var spr = new Sprite (16, 32);
spr.AddTexture (Resource.GetTexture("media/Projectile.png"));
spr.SetOffset (-8, 16);
var col = new SphereCollision (10);
//col.DrawEnabled = true;
var node = new Node ("Projectile");
node.Attach (cmp);
node.Attach (spr);
node.Attach (col);
node.Translation = pos;
node.Rotation = rot;
return node;
}
示例11: Create
private static Node Create(string nodeName, string tankName, Vector3 pos, Quaternion rot)
{
// タンク
var cmp = new MyTank (tankName);
// 車両(Body)
var spr = new Sprite (40, 64);
spr.SetOffset (-20, -34);
spr.AddTexture (cmp.BodyTexture);
spr.AddTexture (Resource.GetDefaultTexture ());
// コリジョン他
var col = new BoxCollision (20, 32, 0);
var node = new Node (nodeName);
node.Attach (cmp);
node.Attach (spr);
node.Attach (col);
// 砲台(Turret)
var tullet = MyTullet.Create ();
tullet.GetComponent<Sprite> ().AddTexture (cmp.turretTexture);
node.AddChild (tullet);
node.DrawPriority = -2;
node.Translation = pos;
node.Rotation = rot;
return node;
}
示例12: Test_SetOffset
public void Test_SetOffset()
{
var spr = new Sprite (64, 64);
spr.Offset = new Vector2(1,2);
Assert.AreEqual (1, spr.Offset.X);
Assert.AreEqual (2, spr.Offset.Y);
spr.SetOffset (3, 4);
Assert.AreEqual (3, spr.Offset.X);
Assert.AreEqual (4, spr.Offset.Y);
}