<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>cocos2d for iPhone &#187; Topic: How to use sensors?</title>
		<link>http://www.cocos2d-iphone.org/forum/topic/2428</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 01:38:31 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.cocos2d-iphone.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.cocos2d-iphone.org/forum/rss/topic/2428" rel="self" type="application/rss+xml" />

		<item>
			<title>eshirt on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16802</link>
			<pubDate>Thu, 29 Oct 2009 00:00:40 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">16802@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/1039'>blackmouth</a> &#38; XyrisKenn - somehow I completely overlooked your reply yesterday.  I do have it working, but I will be sure to read through that excellent post.  It looks like it will clear up a lot of loose ends for me on the whole contact listener topic.  </p>
<p>Thanks for your help - all of you.  @<a href='http://www.cocos2d-iphone.org/forum/profile/145'>bradparks</a> is right, this has been difficult with so little documentation on the current build of box2d.  I'm glad I found you guys on here or I would have been completely lost!  :)
</p></description>
		</item>
		<item>
			<title>XyrisKenn on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16754</link>
			<pubDate>Wed, 28 Oct 2009 17:41:41 +0000</pubDate>
			<dc:creator>XyrisKenn</dc:creator>
			<guid isPermaLink="false">16754@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/1039'>blackmouth</a>, you're welcome, glad the post was useful. Thanks for mentioning it. @<a href='http://www.cocos2d-iphone.org/forum/profile/1743'>eshirt</a> and bradparks, I'll be learning from your posts when I start adding sensors :)
</p></description>
		</item>
		<item>
			<title>bradparks on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16692</link>
			<pubDate>Wed, 28 Oct 2009 00:03:37 +0000</pubDate>
			<dc:creator>bradparks</dc:creator>
			<guid isPermaLink="false">16692@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>good to hear it worked out! as for my circular reference stuff, all it does is let me always get a sprite from a body, or body from a sprite, whichever I happen to be using at the time.... i honestly can't say if I use it that way or not though! I just copied this from the Box2d examples and it seemed to work ;-) But I've found finding how the Box2d stuff works hard, especially since we're out of sync with the public release....
</p></description>
		</item>
		<item>
			<title>blackmouth on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16691</link>
			<pubDate>Tue, 27 Oct 2009 23:55:52 +0000</pubDate>
			<dc:creator>blackmouth</dc:creator>
			<guid isPermaLink="false">16691@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>eshirt,</p>
<p>You'll need to check both fixtureA and fixtureB due to the way the contact listener works. </p>
<p>XrisKenn has a good blog post that helped me implement my contact listener.<br />
<a href="http://blog.xyris.ca/?p=40" rel="nofollow">http://blog.xyris.ca/?p=40</a></p>
<p>Thanks Xyris!
</p></description>
		</item>
		<item>
			<title>eshirt on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16676</link>
			<pubDate>Tue, 27 Oct 2009 21:37:19 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">16676@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Yep, that was it - I'm able to check for UserData and distinguish between multiple sensors.  Looking in the class declaration, I can't see any clear rule about which contacts get labeled FixtureA() and FixtureB().  But my C++ is beginner level, at best, so maybe it's in there and I don't see it.  :)
</p></description>
		</item>
		<item>
			<title>eshirt on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16675</link>
			<pubDate>Tue, 27 Oct 2009 21:31:13 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">16675@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>So, I just typed up a really long reply that explained what I was trying to do, and in the process, I realized that I had always been testing contact-&#62;GetFixtureB() as my sensor.  As soon as I put this in my ContactListener</p>
<pre><code>b2Fixture *actor1 = contact-&#62;GetFixtureA();

if (actor1-&#62;IsSensor()) {
// log contact
}</code></pre>
<p>It worked.  Is there a consistent rule for contact-&#62;fixture A &#38; B - like "a sensor is always fixtureA()"?  Or do I need to write these if() statements assuming that either could be a sensor?</p>
<p>I'll work on integrating my userData back into the sensors and try to get it to work, knowing that FixtureA() is the sensor.
</p></description>
		</item>
		<item>
			<title>Lam on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16671</link>
			<pubDate>Tue, 27 Oct 2009 21:07:03 +0000</pubDate>
			<dc:creator>Lam</dc:creator>
			<guid isPermaLink="false">16671@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>What's the context of that if statement?</p>
<p>What are you trying to do that needs access to UserData again?</p>
<p>Because maybe there's another alternative to what you are attempting.<br />
Other than that, the if statement you used is the same as mine. That's the problem with code sometimes. The simplest statements make sense and the idea is right but there's always some logical error that's hard to detect in the actual code that breaks it. =/
</p></description>
		</item>
		<item>
			<title>eshirt on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16666</link>
			<pubDate>Tue, 27 Oct 2009 20:21:28 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">16666@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Given a body with UserData of myData...</p>
<p>Would I use</p>
<p><code>[actor2-&#62;GetBody()-&#62;GetUserData() isEqual:myData];</code></p>
<p>?
</p></description>
		</item>
		<item>
			<title>Lam on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16665</link>
			<pubDate>Tue, 27 Oct 2009 20:17:10 +0000</pubDate>
			<dc:creator>Lam</dc:creator>
			<guid isPermaLink="false">16665@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Userdata could be applied to the body. I've done that and it works for me. I've seen your thread on user data issue. I'm not quite sure why you were having problems so I didn't know how to respond to help.
</p></description>
		</item>
		<item>
			<title>eshirt on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16661</link>
			<pubDate>Tue, 27 Oct 2009 19:59:31 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">16661@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Looks like you're doing something pretty similar.  The only difference is your userData property...  I haven't seen it done that way, can you elaborate?  It looks like you're doing this the way the box2d documentation suggests - assigning userData to an object and a body, creating a circular reference.  I just haven't been able to figure that one out for myself yet .</p>
<p>I'll try to get it to work with isSensor, but I actually have 2 sensors that need to trigger different actions, so I have applied user data to them.  I think now my trouble is accessing that user data appropriately.  I'm assuming that I need to apply the UserData to my Fixture, not the Body - in order to get the returned fixture isSensor to work?
</p></description>
		</item>
		<item>
			<title>bradparks on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16659</link>
			<pubDate>Tue, 27 Oct 2009 19:51:38 +0000</pubDate>
			<dc:creator>bradparks</dc:creator>
			<guid isPermaLink="false">16659@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Here's the routine I'm using to add sensors.... I just pass "isSensor:YES", and it works for me....</p>
<pre><code>-(void) addStaticShapeAtCoords:(CocosNode *) node pos:(CGPoint)pos width:(int) width height:(int) height isSensor:(BOOL)isSensor
  {
    // Define the body.
    b2BodyDef staticBodyDef;
    staticBodyDef.position.Set(pos.x/tileSize, pos.y/tileSize);
    staticBodyDef.userData = node;

    // Define the box shape.
    b2PolygonShape staticBox;

    // The extents are the half-widths of the box.
    staticBox.SetAsBox(.5f * (width / tileSize) , .5f * (height / tileSize));

    // Define the fixture. This binds a shape (geometry) to a
    // body (dynamics).
    b2FixtureDef staticFixtureDef;
    staticFixtureDef.shape = &#38;staticBox;
    staticFixtureDef.friction = 2.0f;
    staticFixtureDef.isSensor = isSensor;

    // Add the fixture to the body.
    b2Body* staticBody = world-&#62;CreateBody(&#38;staticBodyDef);
    staticBody-&#62;CreateFixture(&#38;staticFixtureDef);
    if (node != nil)
      node.userData = staticBody;
  }</code></pre></description>
		</item>
		<item>
			<title>eshirt on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16656</link>
			<pubDate>Tue, 27 Oct 2009 19:35:19 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">16656@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Aren't sensors just supposed to act like any other object in the collision listener?  I can't get them to register, even though solid bodies trigger contacts perfectly.  I'm guessing that my sensor is just being created incorrectly, but I'm looking at SensorTest and I don't see much difference (except that I'm adding UserData).</p>
<p>I can't find any other examples on the web either...  anyone have this working?
</p></description>
		</item>
		<item>
			<title>eshirt on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-16562</link>
			<pubDate>Tue, 27 Oct 2009 04:41:54 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">16562@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>XyrisKenn - did you ever get sensors working?  I've implemented the ContactListener successfully using your suggestions above and some other posts here.  After having so much trouble with some other aspects of Box2d, I was amazed how easy it was to get a simple collision detection.  :)</p>
<p>But now I'm not able to get my sensor to trigger.  Can anyone tell me what I might be doing wrong?  I looked at the test bed and SensorTest, but I can't find my error.  </p>
<p>In ContactListener.mm</p>
<pre><code>void ContactListener::BeginContact(b2Contact *contact) {
	b2Fixture *actor1 = contact-&#62;GetFixtureA();
	b2Fixture *actor2 = contact-&#62;GetFixtureB();

	if([(AtlasSprite *)actor1-&#62;GetUserData() isEqual:@&#34;mySpriteSel&#34;] &#38;&#38; [(AtlasSprite *)actor2-&#62;GetUserData() isEqual:@&#34;yourSprite&#34;]) {
			// mySpriteSel and yourSprite are set as UserData in MyGame.mm
			NSLog(@&#34;CONTACT!!!!&#34;);  // this works
		}

	if ([(AtlasSprite *)actor1-&#62;GetUserData() isEqual:@&#34;mySpriteSel&#34;] &#38;&#38; [actor2-&#62;GetUserData() isEqual:@&#34;mySensor&#34;]) {
		NSLog(@&#34;Sensor activated!!!!&#34;);  // this doesn&#39;t
	}</code></pre>
<p>and in MyGame.mm</p>
<pre><code>// Set contact listener in -(void)init
ContactListener *contactListener = new ContactListener;
world-&#62;SetContactListener(contactListener);

// Create sensor body and fixture
b2BodyDef sensorBd;
sensorBd.position.Set(-5.5,5);
b2Body *mySensor = world-&#62;CreateBody(&#38;sensorBd);
b2PolygonShape sensorShape;
sensorShape.SetAsBox(0.9, 6.4);
b2FixtureDef sensorFd;
sensorFd.shape = &#38;htEndZoneShape;
sensorFd.isSensor = true;
b2Fixture *fixture = mySensor-&#62;CreateFixture(&#38;sensorFd);
fixture-&#62;SetUserData(@&#34;mySensor&#34;);</code></pre>
<p>I think that should be all the relevant code.
</p></description>
		</item>
		<item>
			<title>XyrisKenn on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-15303</link>
			<pubDate>Tue, 13 Oct 2009 18:09:55 +0000</pubDate>
			<dc:creator>XyrisKenn</dc:creator>
			<guid isPermaLink="false">15303@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi, thanks for this link. I'd seen that in the testbed, but this example seems clearer. I'll try it for the sensor use after integrating ContactListener.</p>
<p>Also, I looked at the source kindly provided by the 'Luke' at Metal Fish Eggs, in the first thread link: <a href="http://blog.zincroe.com/2009/05/iphone-and-box2d/" rel="nofollow">http://blog.zincroe.com/2009/05/iphone-and-box2d/</a><br />
..which gave me an understanding of the 'Actors' approach being used by others in thread <a href="http://www.cocos2d-iphone.org/forum/topic/2057#post-12939" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/2057#post-12939</a>. </p>
<p>However Luke's example uses the regular UIKit framework and I'd like to use Cocos2D and OpenGLes. </p>
<p>So I started synthesizing the two approaches, integrating Luke's Actor.m and ContactListener.m(m) with pabloruiz55's/Rolando's notes, and updating to what I understand of the newest Box2d API in Cocos2d 0.8.02 . </p>
<p>ContactListener isn't throwing compile errors which is a success, but the simulator is freezing on first contact.<br />
I think it's because I'm only half-way integrated right now.</p>
<p>Here are the changes I made so far, using the cocos2d-iphone-0.8.2-rc0 source. Next I'll continue integrating the physics setup and timing.<br />
Caution, the GameLayer code is incomplete and shows only relevant excerpts from my work, built up from the Cocos Box2d template.</p>
<p>1. Actor.h and .m are the same as in Luke's example on blog.zincroe.com.</p>
<p>--------------------------------<br />
2a. ContactListener.h</p>
<pre><code>#include &#34;Box2D.h&#34;

class ContactListener : public b2ContactListener {
public:
	void BeginContact(b2Contact *contact);
	void EndContact(b2Contact *contact);
};</code></pre>
<p>--------------------------------------</p>
<p>2b. ContactListener.mm<br />
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;ContactListener.h&#34;
#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;Actor.h&#34;

void ContactListener::BeginContact(b2Contact *contact) {
	Actor *actor1 = (Actor *)contact-&#62;GetFixtureA()-&#62;GetBody()-&#62;GetUserData();
	Actor *actor2 = (Actor *)contact-&#62;GetFixtureB()-&#62;GetBody()-&#62;GetUserData();
	if(actor1 &#38;&#38; actor2) {
		[actor1 addContact:actor2];
		[actor2 addContact:actor1];
	}
}

void ContactListener::EndContact(b2Contact *contact) {
	Actor *actor1 = (Actor *)contact-&#62;GetFixtureA()-&#62;GetBody()-&#62;GetUserData();
	Actor *actor2 = (Actor *)contact-&#62;GetFixtureB()-&#62;GetBody()-&#62;GetUserData();
	if(actor1 &#38;&#38; actor2) {
		[actor1 removeContact:actor2];
		[actor2 removeContact:actor1];
	}
}</code></pre>
<p>----------------------</p>
<p>3a. GameLayer.h (derived from HelloWorld.h / Cocos2d 0.8.2 Box2D template and instead of Luke's MyGameViewController.h)</p>
<p>...<br />
<pre><code>@class Actor;

@interface GameLayer : Layer {
	NSMutableSet *actorSet;
	b2ContactListener *contactListener;

        b2World *world;</code></pre>
<p>...<br />
}</p>
<pre><code>-(void)addActor:(Actor *)anActor;
-(void)removeActor:(Actor *)anActor;
-(void)removeAllActors;

...
// returns a Scene
+(id) scene;

@end</code></pre>
<p>-----------------------</p>
<p>3b. GameLayer.mm</p>
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;GameLayer.h&#34;
#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;Actor.h&#34;
#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;ContactListener.h&#34;

@interface GameLayer()

#pragma mark Actor Properties
@property (nonatomic, retain) NSMutableSet *actorSet;

#pragma mark Physics Properties
@property (nonatomic, readwrite) b2ContactListener *contactListener;
@property (nonatomic, readwrite) b2World *world; 

@end
...
#pragma mark Actor Accessors

@synthesize actorSet;

#pragma mark Actor Methods

-(void)addActor:(Actor *)anActor {
	if (anActor &#38;&#38; ![[self actorSet] containsObject:anActor]) {
		[anActor setGame:self];
		[[self actorSet] addObject:anActor];
		[anActor actorDidAppear];
	}
}

-(void)removeActor:(Actor *)anActor {
	if(anActor &#38;&#38; [[self actorSet] containsObject:anActor]) {
		[anActor retain];
		[anActor actorWillDisappear];
		[[self actorSet] removeObject:anActor];
		[anActor setGame:nil];
		[anActor release];
	}
}

-(void)removeAllActors {
	for(Actor *anActor in [NSSet setWithSet:[self actorSet]]) {
		[self removeActor:anActor];
	}
}

#pragma mark Physics Accessors
@synthesize contactListener;
@synthesize world;

-(id) init
{
	if( (self=[super init])) {
        mainLayer = self;
...
// set contactListener
	contactListener = new ContactListener;
	world-&#62;SetContactListener(contactListener);
...
    }
	return self;
}</code></pre></description>
		</item>
		<item>
			<title>bradparks on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-15265</link>
			<pubDate>Tue, 13 Oct 2009 11:56:56 +0000</pubDate>
			<dc:creator>bradparks</dc:creator>
			<guid isPermaLink="false">15265@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey there... Glad it helped... and I'm sure you found it through your browsing around, but here's a specific test from the Box2d test bed that addresses sensors... I thought that I'd linked to that before, but when I tried, it didn't get to it... I've tinyurl'd it to make sure it gets through this time!</p>
<p><a href="http://tinyurl.com/box2dsensortest" rel="nofollow">http://tinyurl.com/box2dsensortest</a>
</p></description>
		</item>
		<item>
			<title>XyrisKenn on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-15246</link>
			<pubDate>Tue, 13 Oct 2009 06:52:49 +0000</pubDate>
			<dc:creator>XyrisKenn</dc:creator>
			<guid isPermaLink="false">15246@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thank you bradparks. I've spent hours going through these examples and the reference post you list. The problems I'm encountering as a newbie to Box2d in cocos2d is that the contactListener has just been revised in a way that breaks earlier tutorials, and the testbed files are actually a large collection of different effects. The techniques are buried in there, but difficult to isolate as a simple example of contacts and callbacks because of the testbed's complexity.</p>
<p>It looks in the testbed/ iPhoneTest.h as if the public b2ContactListener is wrapped around variables to do with entire game parameters, while the examples kindly displayed in the link are more focused and refined, but missing included super or subclasses. Or it seems so to me.</p>
<p>I came across an example of a technique to customize the contact information in a game-friendly way, i.e. if contact is ball and tree, then tree explode, but again incorporates super and subclasses not available to study. </p>
<p>As an early learner, finding a straightfoward, focused example of contactListener and callbacks would be extremely helpful.<br />
My experience is in actionscript OOP, where the listener/callbacks seem a bit easier to assign.<br />
Box2D is excellent complex and free software, but getting started with listeners and multitouch is a bit difficult.</p>
<p>Thanks again for sharing your time with the links above.
</p></description>
		</item>
		<item>
			<title>bradparks on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-15197</link>
			<pubDate>Mon, 12 Oct 2009 17:05:45 +0000</pubDate>
			<dc:creator>bradparks</dc:creator>
			<guid isPermaLink="false">15197@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>You have to implement a b2ContactListener to "listen" for collisions... this needs to be done for sensors too....</p>
<p>This discussion talks about it... careful when you're looking at samples, as the function parameters have changed a bit... I think this discussion points them out correctly near the bottom:</p>
<p><a href="http://www.cocos2d-iphone.org/forum/topic/2057#post-12939" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/2057#post-12939</a></p>
<p>Also, if you haven't checked it out, the latest svn version of cocos has it in it in one of the samples (b2ContactListener)</p>
<p><a href="http://www.google.com/codesearch/p?hl=en&#038;sa=N&#038;cd=5&#038;ct=rc#PWa7F9gP7VU/trunk/tests/Box2DTestBed-Cocos2dIntegration/iPhoneTest.h&#038;q=b2contactlistener%20package:http://cocos2d-iphone" rel="nofollow">http://www.google.com/codesearch/p?hl=en&#038;sa=N&#038;cd=5&#038;ct=rc#PWa7F9gP7VU/trunk/tests/Box2DTestBed-Cocos2dIntegration/iPhoneTest.h&#038;q=b2contactlistener%20package:http://cocos2d-iphone</a>\.googlecode\.com
</p></description>
		</item>
		<item>
			<title>XyrisKenn on "How to use sensors?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2428#post-15185</link>
			<pubDate>Mon, 12 Oct 2009 16:19:47 +0000</pubDate>
			<dc:creator>XyrisKenn</dc:creator>
			<guid isPermaLink="false">15185@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello forum,</p>
<p>I'm a Canadian in the Czech Republic, and new to the forum and Cocos2D. </p>
<p>I've a small game running in which the player tries to score a goal like in a football game. </p>
<p>The sensors are boxes in place where the goals would be, but I can't figure out how to detect when they are hit by the ball, as in scoring a goal. </p>
<p>I've checked the sensorTest file and searched the forum and web, and Box2D's forum, but have not found anything I understand.</p>
<p>Any help appreciated, thank you.</p>
<p>---------------------------<br />
//Sensor creation:<br />
// player one goal<br />
CGSize screenSize = [Director sharedDirector].winSize;</p>
<p>b2BodyDef goalOneBodyDef;<br />
goalOneBodyDef.position.Set(((screenSize.width/PTM_RATIO)/2), 0.15);<br />
goalOne = _world-&#62;CreateBody(&#38;goalOneBodyDef);</p>
<p>// add dynamic box for goal<br />
b2PolygonShape goalOneShapeDef;<br />
goalOneShapeDef.SetAsBox(2.0f, 0.05f);</p>
<p>b2FixtureDef goalOneFixtureDef;<br />
goalOneFixtureDef.shape = &#038;goalOneShapeDef;<br />
goalOneFixtureDef.isSensor = true;</p>
<p>// add to body<br />
goalOne-&#62;CreateFixture(&#38;goalOneFixtureDef);</p>
<p>--------------------------------------------</p>
<p>//tick checks:<br />
-(void)tick:(ccTime) dt{<br />
_world-&#62;Step(dt, 10, 8);<br />
for(b2Body* b = _world-&#62;GetBodyList();b;b=b-&#62;GetNext())<br />
  {<br />
    if(b-&#62;GetUserData()!=NULL)<br />
    {<br />
    Sprite* puckData = (Sprite*)b-&#62;GetUserData();</p>
<p>    puckData.position = CGPointMake(b-&#62;GetPosition().x * PTM_RATIO, b-&#62;GetPosition().y * PTM_RATIO);<br />
    }<br />
   }<br />
}
</p></description>
		</item>

	</channel>
</rss>

