本文整理汇总了C#中GameEntity.SetSprite方法的典型用法代码示例。如果您正苦于以下问题:C# GameEntity.SetSprite方法的具体用法?C# GameEntity.SetSprite怎么用?C# GameEntity.SetSprite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameEntity
的用法示例。
在下文中一共展示了GameEntity.SetSprite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGameEntity
public GameEntity CreateGameEntity(string gameEntName, string spriteName)
{
GameEntity newEnt = new GameEntity(gameEntName);
newEnt.SetSprite(Sprite.GetSpriteByName(spriteName));
this.AddGameEntity(newEnt);
return newEnt;
}
示例2: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
game = new Game();
game.Initialize(panel1, panel1.DisplayRectangle.Size);
game.InitializeGraphics();
game.InitializeSound();
game.InitializeResources();
game.InternalUpdate();
this.Show();
gameTickTimer.Enabled = true;
animationTimer.Enabled = true;
control = new GameController(game, new GameMap(new Size(32, 32), new Size(24, 24)));
hoverTile = new GameEntity();
hoverTile.AddSprite("hover", new GameSprite(new SpriteFrame(new SpriteImage("resources/images/hover_tile.png", Color.Transparent), 1)));
hoverTile.SetSprite("hover");
hoverTile.ZIndex = 200; // * Hold den nær jorden ift. infantry som er på 100
hoverTile.IsSelectable = false;
RifleInfantry testUnit1 = new RifleInfantry();
RifleInfantry testUnit2 = new RifleInfantry();
RifleInfantry testUnit3 = new RifleInfantry();
RifleInfantry testUnit4 = new RifleInfantry();
testUnit1.WorldPosition = new Point(2, 2);
testUnit2.WorldPosition = new Point(4, 1);
testUnit3.WorldPosition = new Point(4, 2);
testUnit4.WorldPosition = new Point(4, 3);
testUnit1.MoveSpeed = 20;
testUnit2.MoveSpeed = 50;
testUnit3.MoveSpeed = 50;
testUnit4.MoveSpeed = 40;
control.PlaceEntity(testUnit1);
control.PlaceEntity(testUnit2);
control.PlaceEntity(testUnit3);
control.PlaceEntity(testUnit4);
control.PlaceEntity(hoverTile);
// * Lav lidt skov
Random rand = new Random();
for(int i = 0; i < 15; i++)
{
GameEntity tree = new GameEntity();
tree.AddSprite("idle", new GameSprite(new SpriteFrame(new SpriteImage(
GameController.resourceRoot + "/images/trees/" + rand.Next(1, 6) + ".png", Color.Transparent), 1))
);
tree.OccupationMatrix = new bool[2, 2] {
{ false, true },
{ false, false }
};
tree.IsSelectable = false;
tree.SetSprite("idle");
tree.WorldPosition = new Point(
rand.Next(0, control.map.GetSize().Width),
rand.Next(0, control.map.GetSize().Height)
);
control.PlaceEntity(tree);
}
shouldRun = true;
/*
RenderThread renderThread = new RenderThread(new RenderDelegate(this.RenderGame));
ThreadStart threadStart = new ThreadStart(renderThread.Start);
new Thread(threadStart).Start(); // * Start renderingstråden
*/
}