mattbrand Posted November 17, 2017 Share Posted November 17, 2017 I am making a maze game where the player drags their finger to control a ball moving through a maze. I would love to use Phaser physics to block the ball from moving through the walls. Is there a way to do this with Phaser physics and if so, which physics type would be the best suited for this? Link to comment Share on other sites More sharing options...
samid737 Posted November 18, 2017 Share Posted November 18, 2017 This post is related: P2 is sophisticated enough I think. You could try arcade physics, but rotational effects are not considered after collision, so the ball will not spin when colliding with walls (it will in P2, see above post). Arcade physics bodies are always axis aligned, which might be undesirable in your case: p2: arcade: https://codepen.io/Samid737/pen/BRKdWK Link to comment Share on other sites More sharing options...
mattbrand Posted November 18, 2017 Author Share Posted November 18, 2017 Great, thank you so much! Link to comment Share on other sites More sharing options...
samme Posted November 19, 2017 Share Posted November 19, 2017 Some jitter during drag :/ Link to comment Share on other sites More sharing options...
mattbrand Posted November 21, 2017 Author Share Posted November 21, 2017 I made some serious progress with help from @samme. Still not sure what to do in onDragUpdate(), where I catch the case where I want to have the ball be released: if (xDiff > 20.0 || yDiff > 20.0) But I don't know what to do there in order to disable the ball and re-enable it. You can see my attempts, commented out there. Anyone have suggestions for how to "let go" of the ball right there, but still have the ball be enabled for input events and drag? Link to comment Share on other sites More sharing options...
samme Posted November 21, 2017 Share Posted November 21, 2017 You can try sprite.input.stopDrag(pointer); Link to comment Share on other sites More sharing options...
mattbrand Posted November 21, 2017 Author Share Posted November 21, 2017 That is exactly it. Thank you again @samme! Link to comment Share on other sites More sharing options...
Recommended Posts