本文整理汇总了C#中SpriteBatch.addSprite方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.addSprite方法的具体用法?C# SpriteBatch.addSprite怎么用?C# SpriteBatch.addSprite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.addSprite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: updateCharacters
// update location of theseus and the minotaur
public bool updateCharacters()
{
// create new sprite batch
toRender = new SpriteBatch();
// add a blank tile at theseus' last location to wipe other image
toRender.addSprite(myLevel.TileSet["Ground" + checkerGround(theseusLast)], (theseusLast % myLevel.Width), (theseusLast / myLevel.Height));
// add the tile at theseus' last location over the blank tile i.e. return it to normal
if (myLevel.CellCollection[theseusLast].Type != CellType.Ground)
{
toRender.addSprite(myLevel.TileSet[myLevel.CellCollection[theseusLast].Type.ToString()], (theseusLast % myLevel.Width), (theseusLast / myLevel.Height));
}
// place theseus at new location
toRender.addSprite(myLevel.TileSet["Theseus"], (theseusLocation % myLevel.Width), (theseusLocation / myLevel.Height));
// replace minotaurs last location
toRender.addSprite(myLevel.TileSet["Ground" + checkerGround(minotaurLast[0])], (minotaurLast[0] % myLevel.Width), (minotaurLast[0] / myLevel.Height));
if (myLevel.CellCollection[minotaurLast[0]].Type != CellType.Ground)
{
toRender.addSprite(myLevel.TileSet[myLevel.CellCollection[minotaurLast[0]].Type.ToString()], (minotaurLast[0] % myLevel.Width), (minotaurLast[0] / myLevel.Height));
}
// place minotaur at new location
toRender.addSprite(myLevel.TileSet["Minotaur"], (minotaurLocation % myLevel.Width), (minotaurLocation / myLevel.Height));
// draw spritebatch to screen
toRender.runBatch();
// check weither game is won or lost
if (winLose())
{
return true;
}
return false;
}
示例2: buildCells
public void buildCells()
{
GameController.CurrentGame.setRatio();
// create a new sprite batch
toRender = new SpriteBatch();
// clear current game board
GameController.CurrentGame.Renderer.clearAll();
// for the size of the level
for (int i = 0; i < myLevel.LevelSize; i += 1)
{
// add a blank(tiled) background to the sprite batch
toRender.addSprite(myLevel.TileSet["Ground" + checkerGround(i)], (i % myLevel.Width), (i / myLevel.Height));
}
// for every cell in the level
foreach (Cell cell in myLevel.CellCollection)
{
// the cell type as a string for finding textures in tileset dictionary
string cellType = cell.Type.ToString();
// add the image for each cell into the sprite batch
if (cellType != CellType.Ground.ToString())
{
toRender.addSprite(myLevel.TileSet[cellType], getCoords(cell)[0], getCoords(cell)[1]);
}
else
{
toRender.addSprite(myLevel.TileSet["Ground" + checkerGround(myLevel.CellCollection.IndexOf(cell))], getCoords(cell)[0], getCoords(cell)[1]);
}
}
// add theseus, minotaur and exit locations to the sprite batch
toRender.addSprite(myLevel.TileSet["Theseus"], (theseusLocation % myLevel.Width), (theseusLocation / myLevel.Height) );
toRender.addSprite(myLevel.TileSet["Minotaur"], (minotaurLocation % myLevel.Width), (minotaurLocation / myLevel.Height));
toRender.addSprite(myLevel.TileSet["Exit"], (myLevel.ExitLocation % myLevel.Width), (myLevel.ExitLocation / myLevel.Height));
// draw all the sprites to the screen
toRender.runBatch();
}