<?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; Tag: Box2D - Recent Posts</title>
		<link>http://www.cocos2d-iphone.org/forum/tags/box2d</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 02:12:27 +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/tags/box2d" rel="self" type="application/rss+xml" />

		<item>
			<title>Blackmarq20 on "[Box2D] Fixed Time Step Implementation - Thanks UNAGames"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/8922/page/2#post-143536</link>
			<pubDate>Fri, 10 Feb 2012 01:30:27 +0000</pubDate>
			<dc:creator>Blackmarq20</dc:creator>
			<guid isPermaLink="false">143536@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>has anybody used this for animating sprites or does this only apply to physics? </p>
<p>thanks,
</p></description>
		</item>
		<item>
			<title>rickms on "Z order(s) and Layers"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29055#post-143382</link>
			<pubDate>Thu, 09 Feb 2012 01:52:41 +0000</pubDate>
			<dc:creator>rickms</dc:creator>
			<guid isPermaLink="false">143382@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>My comment about batch nodes is very much related to Karl's excellent explanation.    If you have multiple batch nodes,  because of what Karl as explained, you can never do something like:</p>
<p>background sprite: batchnodeA.sprite1<br />
middle sprite: batchnodeB.sprite1<br />
foreground sprite: batchnodeA.sprite2</p>
<p>This also applies to mixing batch node sprites with non-batched sprites.
</p></description>
		</item>
		<item>
			<title>Karl on "Z order(s) and Layers"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29055#post-143379</link>
			<pubDate>Thu, 09 Feb 2012 00:31:34 +0000</pubDate>
			<dc:creator>Karl</dc:creator>
			<guid isPermaLink="false">143379@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Let's say for example that you have two custom nodes: DogNode and CatNode. Those custom nodes have their own children (various body parts, which are implemented as CCSprites). You could lay them out like so:</p>
<p><img src="http://i.imgur.com/Ykuti.png" /></p>
<p>Your layer has 2 children: a dog and a cat.</p>
<p>The dog has 3 sprites as children, and the cat also has 3 sprites inside it.</p>
<p>Dog has a Z order of 0 inside layer (its parent), and cat has a Z order of 1, so dog will always be drawn before cat no matter what order you added them in:</p>
<pre><code>[layer addChild:dog z:0];
[layer addChild:cat z:1];</code></pre>
<p>is exactly the same as:</p>
<pre><code>[layer addChild:cat z:1];
[layer addChild:dog z:0];</code></pre>
<p>Inside cat, body has a z of 0, eyes 10, ears 11, so they always will be in that order.<br />
However, dog has all of them at the same Z order (1000), so then cocos2d falls back on the order you added them in. In this case:<br />
<pre><code>[dog addChild:body z:1000];
[dog addChild:eyes z:1000];
[dog addChild:ears z:1000];</code></pre>
<p>is NOT the same as:<br />
<pre><code>[dog addChild:ears z:1000];
[dog addChild:body z:1000];
[dog addChild:eyes z:1000];</code></pre>
<p>Now when it comes time to render this graph, cocos2d does it like this (simplified):</p>
<pre><code>layer&#039;s parent: draw layer.
    layer: draw dog.
        dog: draw body
        dog: draw eyes
        dog: draw ears
        dog: no more children to draw
    layer:draw cat
        cat: draw body
        cat: draw eyes
        cat: draw ears
        cat: no more children to draw
    layer: no more children to draw
layer&#039;s parent: no more children to draw.</code></pre>
<p>So the order the sprites get drawn in is: dog body, dog eyes, dog ears, cat body, cat eyes, cat ears.<br />
If the cat is in the same location as the dog, the cat comes out over top because the ENTIRE cat gets drawn after the ENTIRE dog. This happens even though the dog's components have a z order of 1000 while the cat's components have Z orders that are smaller. Z order is only relative to your immediate peers (other children of the same parent).
</p></description>
		</item>
		<item>
			<title>mijator on "Z order(s) and Layers"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29055#post-143375</link>
			<pubDate>Wed, 08 Feb 2012 23:57:45 +0000</pubDate>
			<dc:creator>mijator</dc:creator>
			<guid isPermaLink="false">143375@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks.</p>
<p>What I found really useful:</p>
<p>Duckwit: "Except, 'before things get confusing':<br />
If you have a sprite on a layer at z:100, you can have more than 100 sprites below it simply by using negative values."</p>
<p>Rickms: "Particularly important when it comes to batch nodes."  </p>
<p>- I want/need to know what you meant because it may be related to my current problem (i.e., using batch nodes for multiple sprites/layers and having z values get mixed up)...so please, Rickms, explain more about your comment...</p>
<p>Karl: " If you add two nodes with the same z value, they are placed in the same area of the list, but the node you added earlier will always be before the node you added later. When it comes time to draw, cocos2d will step through the list, drawing each child. Children drawn later will overwrite any part that overlaps with a previously drawn child node."</p>
<p>- this is really useful.  Perhaps this is why my previous layer objects have disappeared (i.e., I've overwritten them with newer ones "Children drawn later" )...</p>
<p>Karl: "Either all children of node A will draw before all children of node B, or vice versa"</p>
<p>- perhaps this is the key to understanding things...</p>
<p>i.e., if node B draws after node A...then B overwrites whatever A has done.  </p>
<p>DOES THAT MEAN: whoever draws last takes highest priority?</p>
<p>&#62;&#62;&#62;<br />
It seems to be based upon nodes, so a quick explanation of nodes would be nice<br />
&#62;&#62;&#62;
</p></description>
		</item>
		<item>
			<title>mavrik5150 on "Z order(s) and Layers"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29055#post-143328</link>
			<pubDate>Wed, 08 Feb 2012 22:46:38 +0000</pubDate>
			<dc:creator>mavrik5150</dc:creator>
			<guid isPermaLink="false">143328@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>One thing you should consider as well if you are going to be using the Z tag a lot is setting up a typedef in the .m file and give some of them an name to make it easier to track like </p>
<pre><code>typedef enum {
Layer1Z = 1,
Layer5Z = 20,
etc
}ZLayers</code></pre>
<p>Then when you start adding your different sprites and layers you can actually have a word in the z so things aren't as confusing (ex CCSprite *a-sprite z:Layer1Z). It also helps for when you need to do stuff later and try to track something down based on tag or z order (I do the same for my Tag's that will be used frequently).
</p></description>
		</item>
		<item>
			<title>Karl on "Z order(s) and Layers"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29055#post-143325</link>
			<pubDate>Wed, 08 Feb 2012 21:53:51 +0000</pubDate>
			<dc:creator>Karl</dc:creator>
			<guid isPermaLink="false">143325@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Child nodes are actually stored in a list internally. The "z" value determines their relative position in the list. Higher numbers are placed later in the list than lower numbers. If you add two nodes with the same z value, they are placed in the same area of the list, but the node you added earlier will always be before the node you added later.</p>
<p>When it comes time to draw, cocos2d will step through the list, drawing each child. Children drawn later will overwrite any part that overlaps with a previously drawn child node (unless you're using a custom blend mode).</p>
<p>Each node has its own list of children, so the z value of nodes in different parents have no effect on each other. Either all children of node A will draw before all children of node B, or vice versa.</p>
<p>Also, the z value is just an integer. You could use 100000, for example.
</p></description>
		</item>
		<item>
			<title>rickms on "Z order(s) and Layers"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29055#post-143324</link>
			<pubDate>Wed, 08 Feb 2012 21:48:54 +0000</pubDate>
			<dc:creator>rickms</dc:creator>
			<guid isPermaLink="false">143324@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Yes, this is how it works.   Particularly important when it comes to batch nodes.
</p></description>
		</item>
		<item>
			<title>Duckwit on "Z order(s) and Layers"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29055#post-143323</link>
			<pubDate>Wed, 08 Feb 2012 21:48:36 +0000</pubDate>
			<dc:creator>Duckwit</dc:creator>
			<guid isPermaLink="false">143323@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Yes. You are correct. </p>
<p>Except, 'before things get confusing':<br />
If you have a sprite on a layer at z:100, you can have more than 100 sprites below it simply by using negative values. </p>
<p>e.g:<br />
sprite z:100<br />
sprite z: 90<br />
sprite z:50<br />
sprite z:20<br />
sprite z:10<br />
sprite z:5<br />
sprite z:0<br />
sprite z:-1<br />
sprite z:-10<br />
sprite z: -50<br />
etc...
</p></description>
		</item>
		<item>
			<title>mijator on "Z order(s) and Layers"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29055#post-143322</link>
			<pubDate>Wed, 08 Feb 2012 21:36:09 +0000</pubDate>
			<dc:creator>mijator</dc:creator>
			<guid isPermaLink="false">143322@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Just wondering if I am right about the priority of z orders and layers...</p>
<p>&#62;&#62;&#62;<br />
That is:</p>
<p>Layer 1 : z:0</p>
<p>CCSprite *a-sprite z:100  // a-sprite is contained within Layer 1 so even though it has an individual z order of 100, it stays within the z:0 layer and all objects (on different layers) are above it if the layer they are on is greater than z:0 (see below)</p>
<p>//it also means I can have 99 more sprite "sub layers" within layer 1 before things start to get confusing</p>
<p>Layer 2 z:1  // everything in this layer is above all of the objects in Layer 1</p>
<p>CCSprite *b-sprite z:100 //i.e., even though they have the same z value, b-sprite is NOT in the same layer as a-sprite because it has been created in layer 2...</p>
<p>&#62;&#62;&#62;<br />
Am I right with the above?
</p></description>
		</item>
		<item>
			<title>iforce2d on "[Box2dD] need help on shooting"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28959#post-143203</link>
			<pubDate>Wed, 08 Feb 2012 05:38:22 +0000</pubDate>
			<dc:creator>iforce2d</dc:creator>
			<guid isPermaLink="false">143203@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Solved, I believe: <a href="http://stackoverflow.com/questions/9158820/box2d-impulse-on-release" rel="nofollow">http://stackoverflow.com/questions/9158820/box2d-impulse-on-release</a>
</p></description>
		</item>
		<item>
			<title>benquan on "Box2d setupDebugDraw?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/21311#post-143125</link>
			<pubDate>Tue, 07 Feb 2012 20:46:06 +0000</pubDate>
			<dc:creator>benquan</dc:creator>
			<guid isPermaLink="false">143125@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks! had been looking for this for a couple of days now!
</p></description>
		</item>
		<item>
			<title>kbaren on "Complex shape and Prismatic Joint"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29011#post-143006</link>
			<pubDate>Tue, 07 Feb 2012 09:41:16 +0000</pubDate>
			<dc:creator>kbaren</dc:creator>
			<guid isPermaLink="false">143006@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a dynamic body created by polygon shape with 15 edges, when i try to create a prismatic joint , for body movement restriction on x axis it does not work(i can drag it in whole screen) but when i change complex shape to simple rectangle shape it works fine, and after when i create complex shape and inside it rectangle shape another dynamic (not all bodies ) bodies collides only with rectangle   what i do wrong? is there problem with body mass center or something else?
</p></description>
		</item>
		<item>
			<title>riq on "[wip] endless runner w/ box2d"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28997#post-142944</link>
			<pubDate>Mon, 06 Feb 2012 22:00:20 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">142944@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>it looks good.
</p></description>
		</item>
		<item>
			<title>embero on "[wip] endless runner w/ box2d"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28997#post-142941</link>
			<pubDate>Mon, 06 Feb 2012 21:47:30 +0000</pubDate>
			<dc:creator>embero</dc:creator>
			<guid isPermaLink="false">142941@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Just started to develop my second iOS game with Cocos2D and Box2D for the first time. It took some while to get Box2D running and to understand the basic principles. I wrote a first prototype for my upcoming game and got the procedural terrain working. Technically the terrains is just one b2Body with a bunch of b2Fixtures. These fixtures are added and removed in realtime as needed. </p>
<p>Anyway here is a video which shows the terrain generation.<br />
<a href="http://www.youtube.com/watch?v=QjlkoQiE8-8" rel="nofollow">http://www.youtube.com/watch?v=QjlkoQiE8-8</a>
</p></description>
		</item>
		<item>
			<title>MandarX on "disabling temporarily autorotation"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28989#post-142940</link>
			<pubDate>Mon, 06 Feb 2012 21:46:40 +0000</pubDate>
			<dc:creator>MandarX</dc:creator>
			<guid isPermaLink="false">142940@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I'm using v0.99.5</p>
<p>in GameConfig.h GAME_AUTOROTATION is kGameAutorotationUIViewController</p>
<p>should I set it to kGameAutorotationCCDirector ?</p>
<p>MandarX
</p></description>
		</item>
		<item>
			<title>riq on "disabling temporarily autorotation"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28989#post-142939</link>
			<pubDate>Mon, 06 Feb 2012 21:41:15 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">142939@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>v1.x or v2.0 ?<br />
If v1.x, what kind of rotation did you enable in your GameConfig.h file ?
</p></description>
		</item>
		<item>
			<title>MandarX on "disabling temporarily autorotation"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28989#post-142889</link>
			<pubDate>Mon, 06 Feb 2012 17:45:51 +0000</pubDate>
			<dc:creator>MandarX</dc:creator>
			<guid isPermaLink="false">142889@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello,</p>
<p>Is there a way to tell CCDirector to disable temporarily autorotation?</p>
<p>I tried to comment some lines in <em>shouldAutorotateToInterfaceOrientation</em> and <em>willRotateToInterfaceOrientation</em> functions<br />
and I disabled it but Box2D doesn't work anymore!</p>
<p>MandarX
</p></description>
		</item>
		<item>
			<title>Bananni on "[Box2D] removing ground body"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28962#post-142796</link>
			<pubDate>Sun, 05 Feb 2012 23:52:25 +0000</pubDate>
			<dc:creator>Bananni</dc:creator>
			<guid isPermaLink="false">142796@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>yeah theres a way, make a own CCNode class where you can register bodies in an array and on dealloc circle through the array and remove them.<br />
or<br />
in you onExit method of your CCNode go through the body list of your b2World, then destroy all bodies that have <code>self</code> as it user data.
</p></description>
		</item>
		<item>
			<title>Blackmarq20 on "[Box2D] Fixed Time Step Implementation - Thanks UNAGames"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/8922/page/2#post-142781</link>
			<pubDate>Sun, 05 Feb 2012 21:27:25 +0000</pubDate>
			<dc:creator>Blackmarq20</dc:creator>
			<guid isPermaLink="false">142781@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi, </p>
<p>Can this be used to move sprites as well? or is this only for physics? If so, what value would you add to the position? i.e. <code>(plane.position = ccpAdd(plane.position, ccp(50 * dt, 0));</code>
</p></description>
		</item>
		<item>
			<title>x0661t on "[Box2D] removing ground body"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28962#post-142763</link>
			<pubDate>Sun, 05 Feb 2012 18:57:24 +0000</pubDate>
			<dc:creator>x0661t</dc:creator>
			<guid isPermaLink="false">142763@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/35639'>Bananni</a></p>
<p>thanks, but is there any way of removing only node object and automatically remove all physics bodies? or I should do it by myself?</p>
<p>Thanks!
</p></description>
		</item>
		<item>
			<title>Bananni on "[Box2D] removing ground body"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28962#post-142762</link>
			<pubDate>Sun, 05 Feb 2012 18:53:14 +0000</pubDate>
			<dc:creator>Bananni</dc:creator>
			<guid isPermaLink="false">142762@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>you answered your question allready
</p></description>
		</item>
		<item>
			<title>x0661t on "[Box2D] removing ground body"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28962#post-142761</link>
			<pubDate>Sun, 05 Feb 2012 18:49:14 +0000</pubDate>
			<dc:creator>x0661t</dc:creator>
			<guid isPermaLink="false">142761@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello, I have a CCNode object that has ground body inside it, when i'm removing CCNode object the body still exists, what should I do with such problem? The answer can be like: you should remove ground body on dealloc, but if I'll have 5 to 10 more bodies at this CCNode object, I have to remove them at dealloc method?</p>
<p>Thanks!
</p></description>
		</item>
		<item>
			<title>MandarX on "[Box2D] Inertia"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28924#post-142739</link>
			<pubDate>Sun, 05 Feb 2012 11:59:50 +0000</pubDate>
			<dc:creator>MandarX</dc:creator>
			<guid isPermaLink="false">142739@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks</p>
<p>I think it can help</p>
<p>MandarX
</p></description>
		</item>
		<item>
			<title>sloppyflow on "[Box2dD] need help on shooting"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28959#post-142736</link>
			<pubDate>Sun, 05 Feb 2012 10:57:46 +0000</pubDate>
			<dc:creator>sloppyflow</dc:creator>
			<guid isPermaLink="false">142736@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>So i am trying to create a game sort of like angry bird, which requires player to swipe the ball and shoot based on the angle and distance. I found a tutorial based on Flash Box2D <a href="http://www.emanueleferonato.com/2011/10/10/develop-a-flash-game-like-angry-birds-using-box2d/" rel="nofollow">http://www.emanueleferonato.com/2011/10/10/develop-a-flash-game-like-angry-birds-using-box2d/</a></p>
<p>But i have hard time trying to figure out the conversion.</p>
<p>so in my init, i have create my body object.<br />
<pre><code>CCSprite *tail = [CCSprite spriteWithFile:@&#34;Ball.jpg&#34;];
        [self addChild:tail z:1];

        b2BodyDef tailBodyDef;
        tailBodyDef.type = b2_dynamicBody;
        tailBodyDef.position.Set(100/PTM_RATIO, 100/PTM_RATIO);
        tailBodyDef.userData = tail;
        tailBody = world-&#62;CreateBody(&#38;tailBodyDef);

        b2CircleShape circle;
        circle.m_radius = 26.0/PTM_RATIO;

        b2FixtureDef tailShapeDef;
        tailShapeDef.shape = &#38;circle;
        tailShapeDef.density = 1.0f;
        tailShapeDef.friction = 0.2f;
        tailShapeDef.restitution = 0.8f;
        tailBody-&#62;CreateFixture(&#38;tailShapeDef);

		[self schedule: @selector(tick:)];</code></pre>
<p>I have these code on my touch dispatcher.<br />
<pre><code>- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (mouseJoint != nil) return;

    UITouch *myTouch = [touches anyObject];
    CGPoint location = [myTouch locationInView:[myTouch view]];
    location = [[CCDirector sharedDirector] convertToGL:location];
    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);

    if (locationWorld.x &#60; tailBody-&#62;GetWorldCenter().x + 50.0/PTM_RATIO)
    {
        b2MouseJointDef md;
        md.bodyA = groundBody;
        md.bodyB = tailBody;
        md.target = locationWorld;
        md.maxForce = 2000;

        mouseJoint = (b2MouseJoint *)world-&#62;CreateJoint(&#38;md);
    }
}

- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (mouseJoint == nil) return;

    UITouch *myTouch = [touches anyObject];
    CGPoint location = [myTouch locationInView:[myTouch view]];
    location = [[CCDirector sharedDirector] convertToGL:location];

    float distanceX = location.x-170;
    float distanceY =location.y-270;
    if (distanceX*distanceX+distanceY*distanceY&#62;10000) {
        CGFloat angle = atan2f(distanceY,distanceX);
        location.x=170+100*cosf(angle);
        location.y=270+100*sinf(angle);
    }
    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
    mouseJoint-&#62;SetTarget(locationWorld);
}

- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (mouseJoint != nil) return;

    UITouch *myTouch = [touches anyObject];
    CGPoint location = [myTouch locationInView:[myTouch view]];
    location = [[CCDirector sharedDirector] convertToGL:location];
    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);

    float distanceX = location.x-170;
    float distanceY =location.y-270;
    float distance = sqrtf(distanceX*distanceX+distanceY*distanceY);
    CGFloat angle = atan2f(distanceY,distanceX);

    // Apply an impulse to the body, using the angle
    tailBody-&#62;ApplyLinearImpulse(b2Vec2(-distance*cosf(angle)/4,-distance*sinf(angle)/4), tailBody-&#62;GetPosition());

    if (mouseJoint) {
        world-&#62;DestroyJoint(mouseJoint);
        mouseJoint = NULL;
    }

}</code></pre>
<p>My problem is i couldn't get it to shoot, i was able to drag the body object around, but when i release my finger. the object stays there instead of shoot itself out.<br />
It'll be great if some of you could help me with this!
</p></description>
		</item>
		<item>
			<title>siavash82 on "[Box2D] hovercar suspension rotation"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28908#post-142724</link>
			<pubDate>Sun, 05 Feb 2012 08:08:04 +0000</pubDate>
			<dc:creator>siavash82</dc:creator>
			<guid isPermaLink="false">142724@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks mate working great now. I did have the wrong positions as you said and just needed a little number tweaking.
</p></description>
		</item>
		<item>
			<title>DifferentSparks on "Change scenes and flickering"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28944#post-142691</link>
			<pubDate>Sat, 04 Feb 2012 21:08:52 +0000</pubDate>
			<dc:creator>DifferentSparks</dc:creator>
			<guid isPermaLink="false">142691@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Well, i've 2 scenes, GameOverScene and GamePlayScene. Both of them, have some layers like children (bg,ui ecc).<br />
When my player dies, i just do </p>
<pre><code>[[CCDirector sharedDirector] replaceScene :
             [CCTransitionFade transitionWithDuration : 2.0f
                                                scene : [GameOverScene node]]];</code></pre>
<p>and when the user touches the GameOverLayer</p>
<pre><code>[[CCDirector sharedDirector] replaceScene :
     [CCTransitionFade transitionWithDuration : 1.5f
                                        scene : [GamePlayScene node]]];</code></pre>
<p>Everything is ok, but sometimes, when i come back to the GamePlayScene, all my sprites(with box2d body) are flickering. this happens often if i have some music on the iPhone.</p>
<p>Should i do something for release the old scenes? Can be this the problem?</p>
<p>Currently i have all my GameObjects(CCSprite+Box2d body) in CCMutableArrays , so in the GamePlayerLayer's(GamePlayScene's child) dealloc method i just do</p>
<pre><code>[gameObjectArray release];</code></pre>
<p>Thanks
</p></description>
		</item>
		<item>
			<title>noThree on "[Box2D] hovercar suspension rotation"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28908#post-142690</link>
			<pubDate>Sat, 04 Feb 2012 20:21:33 +0000</pubDate>
			<dc:creator>noThree</dc:creator>
			<guid isPermaLink="false">142690@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>You aren't halving the mass and spring constant values in the final few lines. This may be the problem.</p>
<p>Also, it looks like you aren't using the correct positions when raycasting body-&#62;GetWorldPoint(0,0) is the center of the body.<br />
If you define the box as being 2 metres long and 0.5 metres high... SetAsBox(1,0.25);<br />
Then you would use... GetWorldPoint(-1, 0) and GetWorldPoint(1, 0)</p>
<p>Here is a crappy digram:</p>
<p>R=Rear<br />
M=Middle<br />
F=Front</p>
<p>    R----M----F<br />
-1.0        0        1.0
</p></description>
		</item>
		<item>
			<title>Nexus6 on "[Box2D] Inertia"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28924#post-142636</link>
			<pubDate>Sat, 04 Feb 2012 10:51:45 +0000</pubDate>
			<dc:creator>Nexus6</dc:creator>
			<guid isPermaLink="false">142636@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Are you looking for the linearDamping?<br />
<pre><code>body-&#62;SetLinearDamping(0.5f);</code></pre>
<p>From Box2d manual:<br />
<em><br />
Damping is used to reduce the world velocity of bodies. Damping is different than friction because friction only occurs with contact. Damping is not a replacement for friction and the two effects should be used together.</p>
<p>Damping parameters should be between 0 and infinity, with 0 meaning no damping, and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1. I generally do not use linear damping because it makes bodies look floaty.<br />
Damping is approximated for stability and performance. At small damping values the damping effect is mostly independent of the time step. At larger damping values, the damping effect will vary with the time step. This is not an issue if you use a fixed time step (recommended).<br />
</em>
</p></description>
		</item>
		<item>
			<title>MandarX on "[Box2D] Inertia"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28924#post-142633</link>
			<pubDate>Sat, 04 Feb 2012 09:57:26 +0000</pubDate>
			<dc:creator>MandarX</dc:creator>
			<guid isPermaLink="false">142633@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I try again:</p>
<p>does Box2D provide some control over inerta?</p>
<p>MandarX
</p></description>
		</item>
		<item>
			<title>siavash82 on "[Box2D] hovercar suspension rotation"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28908#post-142622</link>
			<pubDate>Sat, 04 Feb 2012 06:39:02 +0000</pubDate>
			<dc:creator>siavash82</dc:creator>
			<guid isPermaLink="false">142622@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Here is my code, there is also angular damping of 10 set on the body. It seems to be stable when there is no movement but when theres a force it goes out of control. It also starts to bounce uncontrollably when it gets too much height.</p>
<pre><code>-(void)update:(ccTime)dt
{
    // move forward
    b2Vec2 velSpeed = body-&#62;GetLinearVelocity();
    velSpeed.x = 5;
    body-&#62;SetLinearVelocity(velSpeed);

    // hovering up touch
    if(shouldHover){
        body-&#62;ApplyLinearImpulse(b2Vec2(0, 1), body-&#62;GetWorldCenter());
    }

    // rotation
    float32 minAngle = CC_DEGREES_TO_RADIANS(0);
    float32 maxAngle = CC_DEGREES_TO_RADIANS(0);
    double desiredAngle = self.body-&#62;GetAngle();
    if (self.body-&#62;GetAngle() &#62; maxAngle) {
        desiredAngle = maxAngle;
    } else if (self.body-&#62;GetAngle() &#60; minAngle){
        desiredAngle = minAngle;
    }

    float32 diff = desiredAngle - self.body-&#62;GetAngle();
    if (diff != 0) {
        float32 diff = desiredAngle - self.body-&#62;GetAngle();
        float angimp = self.body-&#62;GetInertia() * diff;
        self.body-&#62;ApplyAngularImpulse(angimp * 0.5);
    }

    // ray cast hovering
    float targetHeight = 0.9;
    float springConstant = 100;
    power = 0.25; //0.25
    b2Vec2 rearPos = b2Vec2(0, 0);
    b2Vec2 frontPos = b2Vec2(280/PTM_RATIO, 0); //closest guess to right edge, no visual representation
    RaysCastCallback callback;

    // ray cast rear
    b2Vec2 startOfRayRear = body-&#62;GetWorldPoint(b2Vec2(rearPos));
    b2Vec2 endOfRayRear = body-&#62;GetWorldPoint(b2Vec2(rearPos.x, -5));

    world-&#62;RayCast(&#38;callback, startOfRayRear, endOfRayRear);

    if (callback.m_fixture){
        float distanceAboveGround = (startOfRayRear - callback.m_point).Length();

        if (distanceAboveGround &#60; targetHeight) {
            body-&#62;ApplyForce(body-&#62;GetMass()/2 *- world-&#62;GetGravity(), rearPos);
            distanceAboveGround += power * body-&#62;GetLinearVelocity().y;
            float distanceAwayFromTargetHeight = targetHeight - distanceAboveGround;
            body-&#62;ApplyForce( b2Vec2(0,springConstant/2 * distanceAwayFromTargetHeight), rearPos);
        }
    }

    // ray cast front
    b2Vec2 startOfRayFront = body-&#62;GetWorldPoint(b2Vec2(frontPos));
    b2Vec2 endOfRayFront = body-&#62;GetWorldPoint(b2Vec2(frontPos.x, -5));

    world-&#62;RayCast(&#38;callback, startOfRayFront, endOfRayFront);

    if (callback.m_fixture){
        float distanceAboveGround = (startOfRayFront - callback.m_point).Length();

        if (distanceAboveGround &#60; targetHeight) {
            body-&#62;ApplyForce(body-&#62;GetMass()/2 *- world-&#62;GetGravity(), frontPos);
            distanceAboveGround += power * body-&#62;GetLinearVelocity().y;
            float distanceAwayFromTargetHeight = targetHeight - distanceAboveGround;
            body-&#62;ApplyForce( b2Vec2(0,springConstant/2 * distanceAwayFromTargetHeight), frontPos);
        }
    }

    b2Vec2 startOfRay = body-&#62;GetPosition();
    b2Vec2 endOfRay = body-&#62;GetWorldPoint(b2Vec2(0, -5));

    world-&#62;RayCast(&#38;callback, startOfRay, endOfRay);

    if (callback.m_fixture)
     {
        float distanceAboveGround = (startOfRay - callback.m_point).Length();

        if (distanceAboveGround &#60; targetHeight) {
            body-&#62;ApplyForce(body-&#62;GetMass() *- world-&#62;GetGravity(), body-&#62;GetWorldCenter()); // remove for bouncyness
            distanceAboveGround += power * body-&#62;GetLinearVelocity().y;
            float distanceAwayFromTargetHeight = targetHeight - distanceAboveGround;
            body-&#62;ApplyForce( b2Vec2(0,springConstant*distanceAwayFromTargetHeight), body-&#62;GetWorldCenter());
        }
    }
}</code></pre></description>
		</item>

	</channel>
</rss>

