iso physics collisions listener?

Post your help queries and engine programming questions here

iso physics collisions listener?

Postby fmendez » Tue May 20, 2014 8:01 pm

i'm using IgeEntityCannon to set obstacles in iso.
How to listen collision as happen with IgeBox2d?
fmendez
 
Posts: 1
Joined: Tue May 20, 2014 7:15 pm

Re: iso physics collisions listener?

Postby robaldred » Wed May 21, 2014 4:00 pm

Hello, welcome to the forum.
Please refer to example 6.3-physics-contacts

You'll need to be very familiar with box2d.
You define a box2d contact listener it's a wrapper around the standard box2d collision handling

Code: Select all

ige.box2d.contactListener(
               // Listen for when contact's begin
               function (contact) {
                  console.log('Contact begins between', contact.igeEntityA()._id, 'and', contact.igeEntityB()._id);
               },
               // Listen for when contact's end
               function (contact) {
                  console.log('Contact ends between', contact.igeEntityA()._id, 'and', contact.igeEntityB()._id);
               },
               // Handle pre-solver events
               function (contact) {
                  // For fun, lets allow ball1 and square2 to pass through each other
                  if (contact.igeEitherId('ball1') && contact.igeEitherId('square2')) {
                     // Cancel the contact
                     contact.SetEnabled(false);
                  }

                  // You can also check an entity by it's category using igeEitherCategory('categoryName')
               }
            );



IGE adds a few convenience methods to the b2Contact to give access to the ige entity that's involved in the collision.
Some are shown inaction in the 6.3-physics-contacts example

All the additional methods are:
  • igeEntityA
  • igeEntityB
  • igeEitherId
  • igeEitherCategory
  • igeBothCategories
  • igeEntityByCategory
  • igeEntityById
  • igeEntityByFixtureId
  • igeOtherEntity
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: iso physics collisions listener?

Postby rob » Wed May 21, 2014 6:08 pm

fmendez wrote:i'm using IgeEntityCannon to set obstacles in iso.
How to listen collision as happen with IgeBox2d?

I'm not sure cannon has that feature. Have you checked the cannon docs?
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm


Return to Help & Questions

Who is online

Users browsing this forum: No registered users and 1 guest
cron