Jirka1111 Posted August 15, 2014 Share Posted August 15, 2014 Is there any chance to detect collision between triangle and another sprite? I have a sprite triangle (so with invisible parts) but sadly it's detecting only rectangler shape (it means even with invisible parts of triangle). Link to comment Share on other sites More sharing options...
lewster32 Posted August 15, 2014 Share Posted August 15, 2014 Yes with P2 - you can define arbitrary shapes - but no with Arcade, as the rectangle-only collision is what makes it so fast. Link to comment Share on other sites More sharing options...
Jirka1111 Posted August 15, 2014 Author Share Posted August 15, 2014 Thank you, lewster. I think just replacing ARCADE with P2 is not everything, right? Link to comment Share on other sites More sharing options...
lewster32 Posted August 15, 2014 Share Posted August 15, 2014 No, it's a little more involved, and the performance will suffer, especially on mobile, as P2 is a much more advanced physics engine. I'm afraid I haven't used P2 and can't really give much guidance here, but there are examples of how to use P2 here: http://examples.phaser.io Link to comment Share on other sites More sharing options...
Jirka1111 Posted August 15, 2014 Author Share Posted August 15, 2014 So maybe will be better just using rectangles instead of triangles? I am developing Dont touch the spikes on my own. EDIT: Is there an option which gives me ability to define size of the collision object? I mean, I have 30x30 px object sprite but I want to check collision from center to 10 px (so object's bottom right corner is not at 30,30 position but 20,20? Link to comment Share on other sites More sharing options...
lewster32 Posted August 15, 2014 Share Posted August 15, 2014 You can change the size of the body with body.setSize (see this example), so what you could do is make the body thin and long so it covers just part of the spike. If the player blatantly hits the spike they die, but if they narrowly miss, they won't feel cheated when they hit an invisible corner Jirka1111 1 Link to comment Share on other sites More sharing options...
Jirka1111 Posted August 15, 2014 Author Share Posted August 15, 2014 You are the best! You can understand to what I mean even with my bad english and your solution is simple and great! I think even original Don't touch the spikes is using same technik. Thank you very much. Link to comment Share on other sites More sharing options...
lewster32 Posted August 15, 2014 Share Posted August 15, 2014 I think your English is pretty good to be honest Link to comment Share on other sites More sharing options...
Recommended Posts