2011-09-01 4 views
0
Vector2 firstSquare = new Vector2(camera.location.X/Tile.tilewidth, camera.location.Y/Tile.tileheight); 
int firstX = (int)firstSquare.X; 
int firstY = (int)firstSquare.Y; 

Vector2 squareOffset = new Vector2(camera.location.X % Tile.tilewidth, camera.location.Y % Tile.tileheight); 
int offsetX = (int)squareOffset.X; 
int offsetY = (int)squareOffset.Y; 

이 코드는 xna resources.com 사이트의 타일 엔진 자습서에 있습니다.XNA 게임 스튜디오 4.0 using C#

이 코드에서는 카메라 위치와 벡터 객체 값을 어떻게 알 수 있습니까?

또한 2D보기와 관련하여 카메라보기 및 세계관에 대한 지식이 없습니다.

답변

0

카메라를 오른쪽으로 이동하면 은 실제 카메라를 취급하고 있다고 가정하고 카메라가 도어가 왼쪽으로 움직이고 있음을 보여줍니다 ...

문이 움직이지 않고 카메라 만 움직이고 있습니다.

이 작업은 카메라의 뷰 변환에 의해 처리됩니다.

View = Matrix.CreateTranslation(new Vector3(-_position, 0)) 
         * Matrix.CreateRotationZ(_rotation) 
         * Matrix.CreateScale(new Vector3(_scale, _scale, 1)) 
         * Matrix.CreateTranslation(new Vector3(ViewportScreen.X + ViewportScreen.Width * 0.5f, ViewportScreen.Y + ViewportScreen.Height * 0.5f, 0)); 

이보기 핸들 카메라 회전, 줌, 위치에 중심 :

XNA이 사용됩니다이보기는 2D 카메라 Matrix.CreateLookAt

비록 통해 변환 만들 수있는 방법을 제공합니다.