1
\$\begingroup\$

I am developing a game where I need to zoom in entire map also I can be able zoom out. I have created a tilemap using tiled software and rendered it using phaser.js. How can I add this function to my game?

\$\endgroup\$
0
\$\begingroup\$

First you need to setup your camera like this:

this.camera = this.cameras.main.setBounds(0, 0, 640, 340);

// make the camera follow the player  
this.camera.startFollow(this.player);

// set background color, so the sky is not black  
this.camera.setBackgroundColor('#000000');

And you can set up the zoom like this:

this.camera.zoomTo(  
2, //zoom distance   
1000 // duration/speed of zoom
);
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.