Jump to content

Would love to fix this bug and submit PR, but need consultation


GreatBigBore
 Share

Recommended Posts

I'm pretty sure this is a bug, perhaps even two bugs, and it would be fun to be a true contributor to Phaser, but there are a couple of hurdles. Here's how it goes: arcade physics, circular body, collideWorldBounds = true, bounce = 0. My sprites get up against the world boundary and then can't get away from it. Problem is, inside Phaser.Physics.Arcade.Body#checkWorldBounds(), the sprite is officially out of bounds -- visually, I'm just up against the wall, but internally, I'm out of bounds by the tiniest amount, like 1e-308 (I think this is Number.MIN_VALUE). Seems like that's bug #1: with collideWorldBounds = true, the sprite shouldn't be allowed out of bounds, even by the Planck length. Bug #2 is in how this out-of-bounds condition is handled: checkWorldBounds() multiplies the sprite velocity by -1. That's a problem, if I'm trying to get away from the wall; the function is forcing me back into the wall, and I'm stuck forever.

Or maybe it's three bugs? At the top of checkWorldBounds() there is a decision about whether to use worldBounce or the body bounce for the multiplier; it just uses a negative value, with no consideration for the bounds or the velocity.

Maybe it's all just one bug; I'm not sure. So as I say, I'd love to be a contributor like one of the cool kids, but I'm not sure which aspect(s) should be considered the problem(s). Any advice from the cool kids?

Link to comment
Share on other sites

Consider filing an issue on the Phaser repo and start the discussion there, along with your solutions. If you think the code change is small enough and you've got the time, you could go ahead and solve it and attach it as a pull request before the discussion starts, 'cuz maybe you're totally right and you could just fix it.

Just my opinion, though.

Link to comment
Share on other sites

I guess I'm not destined to be one of the cool kids. I was just about to post that example and realized I had the wrong Phaser tag checked out in my local fork. It doesn't happen with v2.6.2, not sure why. The code in checkWorldBounds() is the same; maybe the Planck length thing got fixed. Sorry for the false alarm.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...