Box2D Forums

It is currently Thu May 23, 2013 8:27 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Feb 10, 2012 9:02 am 
Offline

Joined: Fri Feb 10, 2012 8:55 am
Posts: 2
I am working on a game using Box 2D and Cocos2D, and have turned off gravity as I am simulating a "table top" type game. I am using linear damping to simulate friction. When I need to have the user move a body, I apply a linear impulse based on how the user swipes. It all works great, except on the rare instances when my impulse x value equals the negative of the impulse y value. For example, based on the user swipes, if they swipe exactly at 135 degrees, the impulse value might equal say (-200,200) or if they swipe exactly at 315 degrees the impulse value might equal (200,-200). When this happens no impulse is applied (body doesn't move, or only moves a little). If I test for these scenarios and add a small offset (like .1) to either x or y value, it works fine. I even overrode the touch sensing calculations, and simply applied the impulse directly to make sure my code wasn't the issue.

I plan to strip more of my code out to further isolate the issue (to make sure something else in my code is not causing an issue)

Has anyone else come across this? (I am using the latest stable version of Cocos2d (1.0.1) with Box2d).

Thanks


Top
 Profile  
 
PostPosted: Fri Feb 10, 2012 12:43 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
If I understand this correctly, you're saying that this has no effect?

body->ApplyLinearImpulse( -200, 200 );

I'm not sure how you could isolate the issue better than that... :)
Just as a guess, I would suspect a x/y typo somewhere.


Top
 Profile  
 
PostPosted: Fri Feb 10, 2012 12:54 pm 
Offline

Joined: Fri Feb 10, 2012 8:55 am
Posts: 2
Think I got it solved, it was something else in a completely different section of code when I was checking whether or not the body was at rest.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group