开发者

XNA game studio4.0 using c#

 Vector2 firstSquare = new Vector2(camera.location.X / Tile.tilewidth, camera.location.Y / Tile.tileheight);
 in开发者_StackOverflow社区t 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;

this code is in tile engine tutorial from xna resources.com site.

In this code how can I know about camera location and these vector object values?

and also I don't have knowledge on the camera view and world view with respective to 2d games.


Imagine you are handling a real camera, and you are aiming to a door, if you move the camera to the right... the camera will show to you that the door is moving to the left...

door is not moving, you are only moving the camera.

This action is handled by the view transform of a camera.

Xna provides a way to create this View transform through Matrix.CreateLookAt

Though for a 2D camera is used this:

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 ) );

This View handle camera rotation, zoom, and is centered into position.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜