Exemple #1
0
        void UpdateQuadAt(CCTileMapDrawBufferManager drawBufferManager, int tileCoordX, int tileCoordY, bool updateBuffer = true)
        {
            int flattenedTileIndex    = FlattenedTileIndex(tileCoordX, tileCoordY);
            CCTileGidAndFlags tileGID = TileGIDAndFlagsArray[flattenedTileIndex];

            if (drawBufferManager.TileSetInfo.FirstGid <= tileGID.Gid && drawBufferManager.TileSetInfo.LastGid >= tileGID.Gid || tileGID.Gid == 0)
            {
                CCTileMapVertAndIndexBuffer drawBuffer = drawBufferManager.GetDrawBufferAtIndex(flattenedTileIndex);
                drawBuffer.UpdateQuad(flattenedTileIndex, ref tileGID, updateBuffer);
            }
        }
Exemple #2
0
        void InitialiseDrawBuffers()
        {
            drawBufferManager = new CCTileMapDrawBufferManager(LayerSize.Row, LayerSize.Column);

            // Initialize the QuadsVertexBuffers
            if (tileSetTexture.ContentSizeInPixels != CCSize.Zero)
            {
                for (int y = 0; y < LayerSize.Row; y++)
                {
                    for (int x = 0; x < LayerSize.Column; x++)
                    {
                        UpdateQuadAt(x, y, false);
                    }
                }
            }

            // Initialise the IndexBuffers
            var numOfTiles = (int)NumberOfTiles;

            for (int tileIndex = 0; tileIndex < numOfTiles; tileIndex++)
            {
                var buffer  = drawBufferManager.GetDrawBufferAtIndex(tileIndex);
                var indices = buffer.IndexBuffer.Data;

                int quadVertIndex     = (tileIndex - buffer.TileStartIndex) * NumOfCornersPerQuad;
                int indexBufferOffset = (tileIndex - buffer.TileStartIndex) * NumOfVerticesPerQuad;

                indices[indexBufferOffset + 0] = (short)(quadVertIndex + 0);
                indices[indexBufferOffset + 1] = (short)(quadVertIndex + 1);
                indices[indexBufferOffset + 2] = (short)(quadVertIndex + 2);
                indices[indexBufferOffset + 3] = (short)(quadVertIndex + 3);
                indices[indexBufferOffset + 4] = (short)(quadVertIndex + 2);
                indices[indexBufferOffset + 5] = (short)(quadVertIndex + 1);
            }

            drawBufferManager.UpdateBuffers();
        }
 void UpdateQuadAt(CCTileMapDrawBufferManager drawBufferManager, int tileCoordX, int tileCoordY, bool updateBuffer = true)
 {
     int flattenedTileIndex = FlattenedTileIndex(tileCoordX, tileCoordY);
     CCTileGidAndFlags tileGID = TileGIDAndFlagsArray[flattenedTileIndex];
     if (drawBufferManager.TileSetInfo.FirstGid <= tileGID.Gid && drawBufferManager.TileSetInfo.LastGid >= tileGID.Gid || tileGID.Gid == 0)
     {
         CCTileMapVertAndIndexBuffer drawBuffer = drawBufferManager.GetDrawBufferAtIndex(flattenedTileIndex);
         drawBuffer.UpdateQuad(flattenedTileIndex, ref tileGID, updateBuffer);
     }
 }