Пример #1
0
 public void LoadTileMap(SpriteLoader loader, Point[,] mapIndices, int depth)
 {
     for (int i = 0; i < mapIndices.GetLength(0); ++i)
     {
         for (int j = 0; i < mapIndices.GetLength(1); ++j)
         {
             Point tileCoord = mapIndices[i, j];
             loader.AddSprite(
                 Texture,
                 new Vector2(i * TileWidth, j * TileHeight),
                 new Rectangle(tileCoord.X * TileWidth, tileCoord.Y * TileHeight, TileWidth, TileHeight),
                 depth);
         }
     }
 }
Пример #2
0
 public void LoadTileMap(SpriteLoader loader, Point[,] mapIndices, int depth)
 {
     for (int i = 0; i < mapIndices.GetLength(0); ++i)
     {
         for (int j = 0; i < mapIndices.GetLength(1); ++j)
         {
             Point tileCoord = mapIndices[i, j];
             loader.AddSprite(
                 Texture,
                 new Vector2(i * TileWidth, j * TileHeight),
                 new Rectangle(tileCoord.X * TileWidth, tileCoord.Y * TileHeight, TileWidth, TileHeight),
                 depth);
         }
     }
 }
        //see Triangle2DDrawTest for a general tutorial of the resource loading pattern
        public override void OnLoad(GameState state)
        {
            base.OnLoad(state);
            var tex = Texture.Allocate();
            tex.LoadImageFile("assets/sprite-example.png");

            var loader = new SpriteLoader(BufferUsageHint.DynamicDraw, VertexBuffer.Allocate());
            //TODO: test depth sorting
            loader.AddSprite(
                tex,
                new Vector2(0, 0),             //sprite position (top-left corner)
                new Rectangle(0, 0, 48, 21)    //source rectangle in sprite sheet
            );

            sprites = new DrawableSet(loader.Load());
        }
Пример #4
0
        //see Triangle2DDrawTest for a general tutorial of the resource loading pattern
        public override void OnLoad(GameState state)
        {
            base.OnLoad(state);
            var tex = Texture.Allocate();

            tex.LoadImageFile("assets/sprite-example.png");

            var loader = new SpriteLoader(BufferUsageHint.DynamicDraw, VertexBuffer.Allocate());

            //TODO: test depth sorting
            loader.AddSprite(
                tex,
                new Vector2(0, 0),             //sprite position (top-left corner)
                new Rectangle(0, 0, 48, 21)    //source rectangle in sprite sheet
                );

            sprites = new DrawableSet(loader.Load());
        }