powerman23rus Posted July 8, 2014 Share Posted July 8, 2014 Hello, want to apologize in advance for my English (I use GoogleTranslate). I ask this question about the collision objects. I could not find how to work with the methods collideAgainst, collisionGroup, setCollideAgainst, setCollisionGroup. How can I customize the behavior of the object depending on which object he encountered. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
pinkpanther Posted July 9, 2014 Share Posted July 9, 2014 1) collisionGroup - the native "friendly" group to which the object belongs.2) collisionAgainst - the group of objects, which this objects body would collide. To customize, you should ovverride objects collide() method and there you set the behaviour in case of collision. You could find much more (including link to code examples) in thread http://www.html5gamedevs.com/topic/7569-collision-detection-problem-solved/ powerman23rus 1 Quote Link to comment Share on other sites More sharing options...
maho125 Posted July 9, 2014 Share Posted July 9, 2014 Some examples with physics and collisions you can find here:http://www.demos.tomasmahrik.com/physicsdemo1/http://www.demos.tomasmahrik.com/physicsdemo2/ powerman23rus 1 Quote Link to comment Share on other sites More sharing options...
powerman23rus Posted July 10, 2014 Author Share Posted July 10, 2014 I thank all for the answers. I am interested in the process of creating conflict, ie algorithmics. Doust that igree has to "grenade" that throws the player as the game has to "wall" and to "the enemy." What is the process for determining the "grenades" that she encountered specifically with a "wall" or "enemy" because it affects its behavior in the future. Viewing Documentation in class "body" has a property as you have already said "collideAgainst", which indicates a numeric type "Number". Where does this number, what does it mean? Because property "setCollisionGroup" too "Number". In my understanding, it should be an array of objects, to which is assigned a group number for further detection. Quote Link to comment Share on other sites More sharing options...
powerman23rus Posted July 11, 2014 Author Share Posted July 11, 2014 Sombody! I need help, please! Quote Link to comment Share on other sites More sharing options...
pinkpanther Posted July 14, 2014 Share Posted July 14, 2014 You group friendly objects (e.g.player) in one collisionGroup e.g 0; than you group enemy objects in the collision group e.g. 1. Than you set for friendly objects collideAgainst 1. In case of collision of friendly object (from group 0) against eenym object (group 1), the method collide of friendly object would be called. In this method (override) you set the sepcific action in case of this collision (e.g. removing object). powerman23rus 1 Quote Link to comment Share on other sites More sharing options...
powerman23rus Posted July 14, 2014 Author Share Posted July 14, 2014 Thanks, for the answer Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.