manlyMiniGames.Map.worldToScreen C# (CSharp) Method

worldToScreen() public method

Returns the screen position matching the given world position
public worldToScreen ( Vector2 pos ) : Vector2
pos Vector2 world position
return Vector2
        public Vector2 worldToScreen(Vector2 pos)
        {
            pos -= center;
            pos.X *= scale * TILE_SIZE;
            pos.Y *= scale * TILE_SIZE;
            pos.X += Globals.screenWidth / 2;
            pos.Y += Globals.screenHeight / 2;
            return pos;
        }

Usage Example

        //Draws the sprite to the screen
        public virtual void Draw(SpriteBatch theSpriteBatch, Map map)
        {
            //Find the screen position for the texture
            Vector2 scrpos = map.worldToScreen(mPosition);

            //map.drawOnMap(theSpriteBatch, mSpriteTexture, mPosition, source);
            theSpriteBatch.Draw(mSpriteTexture, scrpos, source, Color.White);
        }
All Usage Examples Of manlyMiniGames.Map::worldToScreen