manlyMiniGames.Map.screenToWorld C# (CSharp) 메소드

screenToWorld() 공개 메소드

Returns the world position relative to the screen position given
public screenToWorld ( Vector2 pos ) : Vector2
pos Vector2 The screen position
리턴 Vector2
        public Vector2 screenToWorld(Vector2 pos)
        {
            pos.X -= Globals.screenWidth / 2;
            pos.Y -= Globals.screenHeight / 2;
            pos.X /= scale * TILE_SIZE;
            pos.Y /= scale * TILE_SIZE;
            pos += center;
            return pos;
        }

Usage Example

예제 #1
0
        private void shootRocket(Map map)
        {
            if (mCurrentState == State.Walking)
            {
                //Check if there are any invisible rockets in the list
                bool    createNewRocket = true;
                Vector2 rocketDirection;
                if (mDirection.X == MOVE_LEFT)
                {
                    rocketDirection = new Vector2(MOVE_LEFT, 0);
                }
                else
                {
                    rocketDirection = new Vector2(MOVE_RIGHT, 0);
                }
                Vector2 rocketStartPosition =
                    map.screenToWorld(new Vector2(mPosition.X + rocketDirection.X * X_FRAME_WIDTH + X_ROCKET_OFFSET,
                                                  mPosition.Y + Y_ROCKET_OFFSET));

                Vector2 rocketSpeed = new Vector2(ROCKET_SPEED, 0);
                foreach (Rocket aRocket in mRockets)
                {
                    if (!aRocket.visible)
                    {
                        createNewRocket = false;
                        aRocket.Fire(rocketStartPosition, rocketSpeed, rocketDirection);
                        break;
                    }
                }

                if (createNewRocket)
                {
                    Rocket aRocket = new Rocket();
                    aRocket.LoadContent(mContentManager);
                    aRocket.Fire(rocketStartPosition, rocketSpeed, rocketDirection);
                    mRockets.Add(aRocket);
                }
            }
        }
All Usage Examples Of manlyMiniGames.Map::screenToWorld