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

[1.2] Added Phaser.Math.setPhysicsPixelRatio() #424

Closed
wants to merge 1 commit into from

Conversation

Fishrock123
Copy link
Contributor

This allows you to set the pixel-physics-unit-scale, vital to support a
wide variety of physics-using games.

@Fishrock123
Copy link
Contributor Author

Additionally, we should consider changing all references of p or physics units to m or meters, as those are the units p2 uses. (Metric; kg & m)

@@ -1299,7 +1313,7 @@ Phaser.Math = {
* @return {number} The scaled value.
*/
p2px: function (v) {
return v *= -20;
return v *= this._pxRatio;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. this won't work here, will it? Phaser.Math._pxRatio?

This allows you to set the pixel-physics-unit-scale, vital to support a
wide variety of physics-using games.
@Fishrock123
Copy link
Contributor Author

Working now, tested and confirmed.

Use case for context: My game involves spaceships that weigh in on the order of some 8000kg, with forces in the tens of thousands of kg. Currently it does not simulate it quite properly, as an entire ship is barely 2 meters wide.

@Fishrock123
Copy link
Contributor Author

@photonstorm I see you changed this stuff a bit... is this a no-go, or should I revise / update to newest commits?

@photonstorm
Copy link
Collaborator

I'm not sure.. I want to provide for this, but I don't want to cause a variable look-up every time px2p is called (or px2m and m2px as they'll be renamed tomorrow). Maybe we could do it via a function remapping, so you can provide your own px2m/m2px functions via the physicsConfig object that exists already and it will use those instead. Actually that might work well, will have a play now.

@photonstorm photonstorm closed this Mar 4, 2014
@Fishrock123 Fishrock123 deleted the 1.2-p2px branch March 14, 2014 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants