Jump to content

About collide methods


powerman23rus
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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