Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-28-2012, 08:19 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 4
mainy is on a distinguished road
Default Box2d three point collision

Hello.

I am using a contact listener to work out when two fixtures collide. This is working as expected.

What I am attempting to do is flag up if three objects collide. I am unsure the best way of doing this and wanted to ask if there is already a standard approach.

Is it possible to first check if two objects collide (using the standard collision listener) and check if they are touching anything else?

Thank you

Last edited by mainy; 01-28-2012 at 08:42 AM.
mainy is offline   Reply With Quote
Old 02-07-2012, 03:50 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Helsinki
Posts: 304
fiftysixty is on a distinguished road
Default

Quote:
Originally Posted by mainy View Post
Hello.

I am using a contact listener to work out when two fixtures collide. This is working as expected.

What I am attempting to do is flag up if three objects collide. I am unsure the best way of doing this and wanted to ask if there is already a standard approach.

Is it possible to first check if two objects collide (using the standard collision listener) and check if they are touching anything else?

Thank you
Use a collision listener, and upon collision you can access the complete collision list for the bodies:

Code:
for (b2ContactEdge* ce = myBody->GetContactList(); ce; ce = ce->next) {

    b2Contact* c = ce->contact;

    // do the checks here
    b2Fixture* fixtureA = c->GetFixtureA();
    b2Body* bodyA = fixtureA->GetBody();

    // etc...
}
fiftysixty is offline   Reply With Quote
Old 02-12-2012, 05:44 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 4
mainy is on a distinguished road
Default

This was a great help. Thank you.

I wrote a recursive method to loop through all connected bodies.
mainy is offline   Reply With Quote
Reply

Bookmarks

Tags
box2d, collision, detection

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 388
8 members and 380 guests
apatsufas, comicool, dansparrow, husthlj, LunarMoon, mer10, Murphy, pbart
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,677
Threads: 94,127
Posts: 402,916
Top Poster: BrianSlick (7,990)
Welcome to our newest member, husthlj
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:06 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0