DodongosQuest.Camera.CenterCameraOnWorldPosition C# (CSharp) Метод

CenterCameraOnWorldPosition() публичный статический Метод

public static CenterCameraOnWorldPosition ( float x, float y ) : void
x float
y float
Результат void
        public static void CenterCameraOnWorldPosition(float x, float y)
        {
            int topLeftX = (int)(x - (1024 / 2));
            int topLeftY = (int)(y - (768 / 2));
            if (topLeftX < 0)
                topLeftX = 0;
            if (topLeftY < 0)
                topLeftY = 0;

            topLeftCornerWorldPosition.X = topLeftX;
            topLeftCornerWorldPosition.Y = topLeftY;
        }

Usage Example

Пример #1
0
        public void CenterCameraOnPlayer()
        {
            Vector2 playerWorldPosition = ConvertTileIndexToWorldPosition(Player.WorldIndex.X, Player.WorldIndex.Y);

            Camera.CenterCameraOnWorldPosition(playerWorldPosition.X, playerWorldPosition.Y);
        }