BliantFive Posted January 25, 2016 Share Posted January 25, 2016 Hi Guys, I'm experiencing a strange behaivior when zooming in and out. While i can grasp(a little) what is happening I have problems solving it. When an object in my game is clicked it is zoomed in. I accomplish this by using game.camera.follow(object, Phaser.Camera.FOLLOW_LOCKON); to keep the object in the center of the view. Then i set: game.world.scale.setTo(x, y); every tick + 0.01 until I hit 1(or close to it) This worked as a cool zoom feature for some time. Now its starting to give me trouble.(I think after changing the wrld bounds and unbounding the camera, but i tried and can't make it work again.) On the first zoom step the object is jumping a few pixels right and down. On the last zoom step the object is juming back to the center. I checked whats happening step by step (by decreasing the tickrate) and to me it looks like the game is doing the following: tick 1 follow with camera zoom in (object is jumping) render tick 2 follow with camera zoom in (object is jumping) render Thats why at the first tick it is jumping and at the last one its jumping back into position. Is there a way to turn around the order? so that its first followed and then directly rendered? This should be possible somehow in the render function, but i just can't get my head around it. Thanks for your help, Mike Link to comment Share on other sites More sharing options...
BliantFive Posted January 25, 2016 Author Share Posted January 25, 2016 Found the Problem after some testing. game.camera.follow(object, Phaser.Camera.FOLLOW_LOCKON); Does basicly the same thing as game.camera.setPositionXY(object.x, object.y); in every tick. But this is wrong when scaling since its locking to the position of the object in the previous scale. correct would be: game.camera.setPositionXY(object.x * newScaleX, object.y * newScaleY); This solved it for me. Zooming is now smooth as wanted. Link to comment Share on other sites More sharing options...
Recommended Posts