0
我跟着教程 http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/實現了一個具有放大/縮小功能的我的玩家精靈的相機。然而,當我放大/縮小照相機時,似乎要麼在緩慢移動的同時離開精靈,我不認爲我正確設置位置,但我似乎無法弄清楚它是什麼需要是。2D遊戲中的XNA矩陣相機刻度問題
這裏的一些片段,如果它有助於
if (cam.Follow)
{
RectangleF temp = playerBoundingBox;
cam.Pos = new Vector2(
(temp.X + temp.Width/2)*cam.Zoom,
temp.Y + temp.Height/2) * cam.Zoom;
}
public Matrix get_transformation(GraphicsDevice graphicsDevice)
{
_transform =
// Add Zoom
Matrix.CreateScale(
new Vector3((_zoom * _zoom * _zoom),
(_zoom * _zoom * _zoom), 0))
// Add Camera Rotation
* Matrix.CreateRotationZ(_rotation)
// Add Camera Position
* Matrix.CreateTranslation(
new Vector3((graphicsDevice.Viewport.Width * 0.5f) - _pos.X,
(graphicsDevice.Viewport.Height * 0.5f) - _pos.Y,
0));
return _transform;
}
預先感謝您。