I’m simply applying the new Vector through the move method. Moving the camera works fine. The problem is that the game STARTS out like that:
As you can see, I am showing the coordinates, the upper ones are the screen coordinates, the lower ones the logical position, so they are the same.
okay. I am drawing it like this:
- spriteBatch.Begin(SpriteSortMode.BackToFront,
_ null, null, null, null, null,
_ cam.Get_transformation(GraphicsDevice));_
_ foreach (Unit u in game_manager.unit_list)_
_ {_
_ _
_ u.Draw();_ ===> at Vector2(400,400)
_ }_
- spriteBatch.End();
Test-wise the unit is supposed to appear at X400, Y400 and since the camera has not moved game position and screen position should be congruent. I’m wondering, previously I was using Monkey X and it worked fine there. I’m just confused… perhaps I am missing something. But there should nothing happen but applying the translate to the logical position to represent it on the screen position… nothing fancy going on
Here is the calculation of the matrix from the linked code:
transform = Matrix.CreateTranslation(new Vector3(-pos.X, -pos.Y, 0)) *
Matrix.CreateRotationZ(Rotation) *
Matrix.CreateScale(new Vector3(Zoom, Zoom, 1))* Matrix.CreateTranslation(new Vector3(graphicsDevice.Viewport.Width * 0.5f, graphicsDevice.Viewport.Height * 0.5f, 0));
Is there something wrong with the viewport * 0.5?