Yanifska Posted May 25, 2015 Share Posted May 25, 2015 hI there, I want to use the main body of a sprite for collisions only, for some kind of platform, and add an invisible sensor that will detect collision only on one side of the sprite and trigger a death reaction.Basically the character can jump on the top of the sprite, but touching the side will trigger the "die" fucntion. My question is: Should I use addRectangle ? it seems to work and it adds a "second body".However how do I detect collision with this second body ?Also is doesn't seems to collide like the main boddy, so what does the sensor property will do ? Edit: I didn't set up collision for the sensor, so I guess that's why it is not colliding, so how do I detect collision / overlap from the sensor ? Link to comment Share on other sites More sharing options...
valueerror Posted May 25, 2015 Share Posted May 25, 2015 http://test.xapient.net/phaser/ALL/moving-jumpthrough-platform-2.html this is one of my first experiments to get jumpthrough platforms to work.. i used two sensors.. the above one disables collision on contact and the lower one enables it... maybe you could read the code and find out what you want ? Yanifska 1 Link to comment Share on other sites More sharing options...
Yanifska Posted May 25, 2015 Author Share Posted May 25, 2015 thank man, I see you are using onBeginContactI was trying to use multiple collide functions each one on specific shapes, but it doesn't seems to work, I guess it should be possible since there are way to specify what shape and groups to collide with. I will try your stuff, however I am a bit in doubt because I have collision groups.In my case the situation is quite opposite, I want each obstacle to have its own sensor Maybe I should have a sensor in front of the character....That gives me ideas... Link to comment Share on other sites More sharing options...
valueerror Posted May 25, 2015 Share Posted May 25, 2015 well.. collisiongroups shouldn't be a problem in general unless you would like to have different collisiongroups for different shapes... (what would be great but i guess that's just not possible right now - correct me if i'm wrong please) the function that is called on contact (either through a collisiongroup callback or an onbegincontact event) has to figure out which shape of the body reported the contact and then act on it accordingly.. should work! Link to comment Share on other sites More sharing options...
Yanifska Posted May 25, 2015 Author Share Posted May 25, 2015 Thanks it helped a lotEdit: maybe it should be added as an example in the phaser example repository ? Link to comment Share on other sites More sharing options...
valueerror Posted May 25, 2015 Share Posted May 25, 2015 hehe.. maybe.. btw. i posted this example because i used sensors of course.. but this is by far not the best way to accomplish what i actually wanted to do there.. (the jumpthrough platform) i managed to get it to work with a totally different approach... (just in case someone needs it ) http://www.html5gamedevs.com/topic/6148-the-moving-jumpthrough-platform-sum-up-thread-help-very-much-appreciated/?p=36930 Link to comment Share on other sites More sharing options...
Yanifska Posted May 26, 2015 Author Share Posted May 26, 2015 I just mean the part about sensors, there is nothing about sensors in phaser docs nor examples, a link to the p2.js website should be added as well.It is very confusing at first valueerror 1 Link to comment Share on other sites More sharing options...
Recommended Posts