Пример #1
0
        public Vec2i worldToGrid(Vector2 pos)
        {
            var x = tiled.WorldToTilePositionX(pos.X);
            var y = tiled.WorldToTilePositionY(pos.Y);

            return(new Vec2i(x, y));
        }
Пример #2
0
        /// <summary>
        /// returns the tile position clamped to the tiled map
        /// </summary>
        /// <returns>The to tile position.</returns>
        /// <param name="worldPosition">World position.</param>
        /// <param name="axis">Axis.</param>
        int WorldToTilePosition(float worldPosition, Axis axis)
        {
            if (axis == Axis.Y)
            {
                return(TiledMap.WorldToTilePositionY(worldPosition));
            }

            return(TiledMap.WorldToTilePositionX(worldPosition));
        }