I want my camera to look down on my space ship.
If I zoom in I want to zoom my space ship closer and closer.
But my camera has a offset and my zoom does not “hit” my ship.
I create my “triangle ship” like this:
var triangle = Phaser.Geom.Triangle.BuildEquilateral(x, y, size); triangle.originX = 0.5; triangle.originY = 0.5; var ref = graphics.fillTriangleShape(triangle); scene.cameras.main.startFollow(ref, false, 1, 1) ; scene.cameras.main.setFollowOffset(0, 0);
And zoom like this:
I want to keep my ship in the dead center of the playing area. If I zoom in I expect the ship (and the world around) to get bigger and bigger. The zoom works and is zooming to the center of the playing area (it seems) but my ship is not in the center.
I have only one explanation for this: The camera has a offset.
I tried to solve it by setting the origin of the camera to 0.5 and setting the camera position to the x,y coordinates of my triangle.
scene.cameras.main.originX = 0.5; scene.cameras.main.originY = 0.5; scene.cameras.main.x = x; scene.cameras.main.y = y; scene.cameras.main.setFollowOffset(0, 0); scene.cameras.main.startFollow(ref, false, 1, 1) ;
I have a missunderstandig of wolrd coordinates, screen coordinates and the phaser camera.
Any idea here?
Thank you so much