小编Bla*_*ple的帖子

使用 Monogame 绘制平铺地图

我一直在尝试实现一个函数,让我可以在平铺文件(.tmx)中绘制平铺。我环顾四周,发现了一种有效的代码,但它拉伸了瓷砖
这是我找到并编辑了一下的代码:

private void DrawLayer(int index, SpriteBatch batch) {
        for (var i = 0; i < Map.Layers[index].Tiles.Count; i++) {
            //Get the identification of the tile
            int gid = Map.Layers[index].Tiles[i].Gid;

            // Empty tile, do nothing
            if (gid == 0) { }
            else {
                int tileFrame = gid - 1 ;
                int column = tileFrame % (tileset.Width / tileWidth);
                int row = tileFrame / (tileset.Height / tileHeight);

                float x = (i % Map.Width) * Map.TileWidth;
                float y = (float)Math.Floor(i / …
Run Code Online (Sandbox Code Playgroud)

c# monogame

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

monogame ×1