Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zoom in or out map #122

Open
Neo-Pz opened this issue Nov 6, 2023 · 3 comments · May be fixed by #152
Open

zoom in or out map #122

Neo-Pz opened this issue Nov 6, 2023 · 3 comments · May be fixed by #152

Comments

@Neo-Pz
Copy link

Neo-Pz commented Nov 6, 2023

How to zoom in or zoom out on a map like Google Earth?

@2642543078
Copy link

hello 你修改下尺寸不可以么

@ketsapiwiq
Copy link

You can check my commit here:
7707c49

@alric05
Copy link

alric05 commented Oct 6, 2024

To reduce the zoom of the map in your simulation and display the full map, you’ll need to adjust the camera’s zoom level in your Phaser game. This can be achieved by modifying the camera settings in your create function or by adjusting the game’s scale configuration. Below, I’ll guide you through both methods and provide code snippets to help you implement the changes.

Method 1: Adjust the Camera’s Zoom Level in the create Function

The most straightforward way to change the zoom level is by setting the camera’s zoom in the create function of your Phaser scene.

Steps:

1.	Locate the Camera Setup in Your create Function:

In your code, find the section where you set up the camera:
// Setting up the camera.
const camera = this.cameras.main;
camera.startFollow(player);
camera.setBounds(0, 0, map.widthInPixels, map.heightInPixels);

  1. Add the setZoom Method:
    Right after setting the camera bounds, add the setZoom method to adjust the zoom level:
    camera.setZoom(0.5); // Adjust the zoom level as needed

• A value of 1 is the default zoom level.
• Values less than 1 will zoom out (e.g., 0.5 will show more of the map).
• Values greater than 1 will zoom in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants