本文整理汇总了C#中Sprite.AddTexture方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.AddTexture方法的具体用法?C# Sprite.AddTexture怎么用?C# Sprite.AddTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.AddTexture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static Node Create(Vector3 pos)
{
var cmp = new MyComponent ();
var spr = new Sprite (480, 300);
spr.AddTexture (new Texture ("media/Vanity.jpg"));
spr.AddTexture (new Texture ("media/Tanks.png"));
spr.AddTexture (new Texture ("media/TatamiRoom.png"));
spr.AutoScale = true;
Console.WriteLine ("tex = " + spr.GetTexture (0));
Console.WriteLine ("spr = " + spr);
var col = new CollisionObject();
col.Shape = new BoxShape(spr.Width/2, spr.Height/2, 100);
col.SetOffset (spr.Width/2, spr.Height/2, 0);
var ctr = new AnimationController ();
var node = new Node ();
node.Attach (cmp);
node.Attach (spr);
node.Attach (col);
node.Attach (ctr);
node.Translation = pos;
var clip = new SoundClip ("Sound");
clip.AddTrack (new SoundEffectTrack ("media/PinPon.wav"));
node.UserData.Add (clip.Name, clip);
return node;
}
示例2: Create
public static Node Create(string name, string target, Vector3 pos)
{
var cmp = new MyButton ();
cmp.target = target;
var spr = new Sprite (64, 64);
spr.AddTexture (new Texture("media/ButtonRed-Active-64x64.png"));
spr.AddTexture (new Texture ("media/ButtonGreen-Active-64x64.png"));
spr.AddTexture (new Texture ("media/ButtonBlue-Active-64x64.png"));
switch (target) {
case "A子": spr.ActiveTexture = 0; break;
case "B子": spr.ActiveTexture = 1; break;
case "C子": spr.ActiveTexture = 2; break;
}
var col = new CollisionObject ();
col.Shape = new BoxShape (40, 25, 1);
col.SetOffset (40, 25, 0);
var node = new Node (name);
node.Attach (cmp);
node.Attach (spr);
node.Attach (col);
node.UserData.Add ("PinPon", new SoundEffectTrack ("media/PinPon.wav"));
node.Translation = pos;
return node;
}
示例3: Test_AddTexture_1
public void Test_AddTexture_1()
{
var spr = new Sprite (64, 64);
spr.AddTexture (new Texture ("abstract7.png"));
spr.AddTexture (new Texture ("image2x2.png"));
Assert.AreEqual (64, spr.Width);
Assert.AreEqual (64, spr.Height);
Assert.AreEqual (2, spr.TextureCount);
Assert.AreEqual ("abstract7.png", spr.GetTexture(0).Name);
Assert.AreEqual ("image2x2.png", spr.GetTexture(1).Name);
}
示例4: Test_AddTexture_2
public void Test_AddTexture_2()
{
var spr = new Sprite ();
spr.AddTexture (new Texture ("abstract7.png"));
spr.AddTexture (new Texture ("image2x2.png"));
// サイズ未指定のスプライトは
// 最初のテクスチャーにあわせられる
Assert.AreEqual (614, spr.Width);
Assert.AreEqual (1024, spr.Height);
Assert.AreEqual (0, spr.ActiveTexture);
Assert.AreEqual (2, spr.TextureCount);
}
示例5: 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;
}
示例6: Create
public static Node Create(Vector3 pos)
{
var cmp = new MySprite ();
var spr = new Sprite (64, 64);
spr.AddTexture (new Texture ("media/Box-64x64.png"));
var col = new CollisionObject ();
col.Shape = new BoxShape (spr.Width / 2, spr.Height / 2, 100);
col.SetOffset (spr.Width / 2, spr.Height / 2, 0);
var mbox1 = new MailBox ("MouseSelect");
var mbxo2 = new MailBox ("MouseDeselect");
var node = new Node ("MySprite");
node.Attach (cmp);
node.Attach (spr);
node.Attach (col);
node.Attach (mbox1);
node.Attach (mbxo2);
node.Translation = pos;
return node;
}
示例7: Create
public static Node Create(string address, Vector3 pos)
{
var cmp = new MySender ();
cmp.address = address;
var spr = new Sprite (64, 64);
spr.AddTexture (Resource.GetDefaultTexture ());
spr.Color = Color.Purple;
var label1 = new Label ();
label1.Text = "Sender";
label1.SetOffset (8, 16);
var label2 = new Label ();
label2.SetOffset (0, -24);
label2.Text = "None";
var node = new Node ("Sender");
node.Attach (cmp);
node.Attach (spr);
node.Attach (label1);
node.Attach (label2);
node.Translation = pos;
return node;
}
示例8: Create
public static Node Create(Vector3 pos)
{
var name = "GameClear";
var cmp = new MyGameClear ();
var spr = new Sprite (200, 160);
spr.AddTexture (new Texture ("media/GameClear.png"));
var clip = new SoundClip ("SoundClip");
clip.AddTrack (new SoundEffectTrack ("media/Announce.ogg"));
clip.Volume = 0.3f;
var mbox = new MailBox (name);
var node = new Node (name);
node.Attach (cmp);
node.Attach (spr);
node.Attach(mbox);
node.UserData.Add (clip.Name, clip);
node.Drawable = false;
node.Translation = pos;
return node;
}
示例9: Create
public static Node Create(string name, string texture, Vector3 pos)
{
var cmp = new MyTarget ();
var spr = new Sprite (64, 128);
spr.AddTexture (new Texture (texture));
var col = new CollisionObject ();
col.Shape = new BoxShape (spr.Width/2, spr.Height/2, 100);
col.SetOffset (spr.Width/2, spr.Height/2, 0);
var mbox1 = new MailBox ("MouseSelect");
var mbox2 = new MailBox ("MouseDeselect");
var node = new Node (name);
node.Attach (cmp);
node.Attach (col);
node.Attach (spr);
node.Attach (mbox1);
node.Attach (mbox2);
node.Translation = pos;
return node;
}
示例10: 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;
}
示例11: Create
public static Node Create(Vector3 pos)
{
var cmp = new MyDeadBox ();
var spr = new Sprite (128, 128);
spr.AddTexture (new Texture ("media/Image128x128(Red).png"));
spr.Color = Color.Gray;
var col = new BoxCollision (spr.Width / 2, spr.Height / 2, 0);
col.SetOffset (spr.Width / 2, spr.Height / 2, 0);
var body = new PhysicsBody ();
body.Shape = col;
body.IsTrigger = true;
var node = new Node ("DeadBox");
node.Attach (cmp);
node.Attach (spr);
node.Attach (col);
node.Attach (body);
node.Translation = pos;
return node;
}
示例12: 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;
}
示例13: Create
public static Node Create(string name, Vector3 pos)
{
var cmp = new MyRecver ();
var spr = new Sprite (64, 64);
spr.AddTexture (Resource.GetDefaultTexture ());
spr.Color = Color.Cyan;
var label1 = new Label ();
label1.Text = name;
label1.SetOffset (4, 16);
var label2 = new Label ();
label2.Text = "None";
label2.SetOffset (0, -24);
var mbox = new MailBox (name);
var node = new Node (name);
node.Attach (cmp);
node.Attach (spr);
node.Attach (label1);
node.Attach (label2);
node.Attach (mbox);
node.Translation = pos;
return node;
}
示例14: Create
public static Node Create(Vector3 pos, int collisionMask)
{
var cmp = new MyBlock ();
var spr = new Sprite (128, 64);
spr.AddTexture (Resource.GetDefaultTexture ());
spr.Color = Color.Cyan;
var col = new CollisionObject ();
col.Shape = new BoxShape (spr.Width/2, spr.Height/2, 1);
col.SetOffset (spr.Width/2, spr.Height/2, 1);
col.CollideWith = collisionMask;
var label = new Label ();
label.Text = "Mask = 0x" + collisionMask.ToString("x");
var node = new Node ("Block");
node.Attach (cmp);
node.Attach (spr);
node.Attach (col);
node.Attach (label);
node.Translation = pos;
return node;
}
示例15: Create
public static World Create()
{
var spr = new Sprite (1920, 1200);
spr.AddTexture (new Texture ("media/Vanity.jpg"));
spr.AddTexture (new Texture ("media/image128x128(Green).png"));
spr.ActiveTexture = 0;
var cmp = new MyWorld ();
cmp.Sprite = spr;
var wld = new World ("First Script");
wld.Attach (cmp);
wld.Attach (spr);
wld.DrawPriority = 127;
return wld;
}