-
Notifications
You must be signed in to change notification settings - Fork 491
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
arcade bodies do not scale with camera #315
Comments
Yes, it's always worked this way. https://codepen.io/samme/pen/OWyPqq Maybe we can scale the body by |
Is it possible to attache listeners to the camera ? n/m i figured this out i believe // init() ...
game.camera.scale.onChange = new Phaser.Signal();
// whenever you change camera scale, dispatch the event
this.game.camera.scale.onChange.dispatch();
// in your sprites, listen to the event
this.game.camera.scale.onChange.add(this.updateBody.bind(this));
// update body
updateBody() {
this.body.setSize(width * this.game.camera.scale.x, ...
} |
That looks good. You can also pass params like this.game.camera.scale.onChange.dispatch(this.game.camera.scale);
// …
updateBody(cameraScale) {
this.body.setSize(/* … */);
} |
ok thanks, here is an example in case anyone is curious. |
I made a branch for this, substituting |
I guess all my sprites had anchor 0.5, thats why there wasnt any offset issues when scaling |
I think it's complicated because with |
maybe it should work like the |
I think the formula in https://github.com/photonstorm/phaser-ce/blob/v2.8.5/src/physics/arcade/Body.js#L618 needs to be changed somehow if |
The real fix here is not to scale physics at all, but instead detach camera scaling from physics entirely. hexus/phaser-ce@master...camera-transform This is a branch I've been working on, but I've only been hesitant to make a PR because it's a big change and will need some testing across all examples. |
Well there's always https://codepen.io/samme/full/ZLbGzB/ 😸 |
Looks great, but changes the resolution of the canvas! Ouch! |
Also looks pretty nice, though it's using CSS, and the world is cropped if you zoom out further than 1x. I still think the best solution is to decouple the camera from the physics, as I've implemented. :) By the way, are you on the Phaser Slack @samme? |
|
This Issue is about
this.game.camera.scale.setTo(2)
See also a potential fix.
RolandMQuiros/phaser@f732cc1
The text was updated successfully, but these errors were encountered: