GetTextureCoordinateVectorsOfTextureIndex() public method

public GetTextureCoordinateVectorsOfTextureIndex ( int textureId ) : Vector2[]
textureId int
return Vector2[]
        /// <summary>
        /// Paints a texture on a tile. This method assumes that the MapDrawableBatch is a perfect recangle with no gaps, and that all
        /// tiles have been added left to right, top to bottom.
        /// </summary>
        /// <param name="row">The row (y) index, base 0</param>
        /// <param name="column">The column (x) index, base 0 </param>
        /// <param name="newTextureId">The texture ID, which is a left to right, top to bottom index</param>
        public void PaintTile(int row, int column, int newTextureId)
        {
            int currentTile   = mMapHeight * column + row;
            int currentVertex = currentTile * 4; // 4 vertices per tile

            // Reusing the coords array saves us on allocation
            mTileset.GetTextureCoordinateVectorsOfTextureIndex(newTextureId, coords);

            mVertices[currentVertex + 0].TextureCoordinate = coords[0];
            mVertices[currentVertex + 1].TextureCoordinate = coords[1];
            mVertices[currentVertex + 2].TextureCoordinate = coords[2];
            mVertices[currentVertex + 3].TextureCoordinate = coords[3];
        }
示例#2
0
        /// <summary>
        /// Paints a texture on a tile.  This method takes the index of the Sprite in the order it was added
        /// to the MapDrawableBatch, so it supports any configuration including non-rectangular maps and maps with
        /// gaps.
        /// </summary>
        /// <param name="orderedTileIndex">The index of the tile to paint - this matches the index of the tile as it was added.</param>
        /// <param name="newTextureId"></param>
        public void PaintTile(int orderedTileIndex, int newTextureId)
        {
            int currentVertex = orderedTileIndex * 4; // 4 vertices per tile

            // Reusing the coords array saves us on allocation
            mTileset.GetTextureCoordinateVectorsOfTextureIndex(newTextureId, coords);

            // Coords are
            // 3   2
            //
            // 0   1

            mVertices[currentVertex + 0].TextureCoordinate = coords[0];
            mVertices[currentVertex + 1].TextureCoordinate = coords[1];
            mVertices[currentVertex + 2].TextureCoordinate = coords[2];
            mVertices[currentVertex + 3].TextureCoordinate = coords[3];
        }