当前位置: 首页>>代码示例>>C#>>正文


C# SpriteBatch.runBatch方法代码示例

本文整理汇总了C#中SpriteBatch.runBatch方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.runBatch方法的具体用法?C# SpriteBatch.runBatch怎么用?C# SpriteBatch.runBatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpriteBatch的用法示例。


在下文中一共展示了SpriteBatch.runBatch方法的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;
 }
开发者ID:parkourben99,项目名称:TheseusAndTheMinotaur,代码行数:31,代码来源:GameInstance.cs

示例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();
        }
开发者ID:parkourben99,项目名称:TheseusAndTheMinotaur,代码行数:39,代码来源:GameInstance.cs


注:本文中的SpriteBatch.runBatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。