2
\$\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\$

1 Answer 1

1
\$\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
);
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .