Box2D Forums

It is currently Sat May 25, 2013 3:19 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Sep 01, 2011 6:20 pm 
Offline

Joined: Wed Aug 31, 2011 6:34 am
Posts: 3
i am using flash pro cs5.5, and WCK latest from github... and i can't get setTransform to work as expected...

So i am working on a simple catapult game where i am launching a ball via a box(the catapult arm) thats on a spring joint.. i can launch the ball fine, i have skinned the ball, etc...

when the ball stops moving, i am checking if it's awake like so :
wrld.ball.bdy.IsAwake() /// btw i have setup bdy like so , public var bdy:b2Body = b2body in the Box class i am extending...

so when the ball stops rolling around, i want to put it back to the starting point so it can be relaunched...
i am doing this :
wrld.bl.bdy.SetTransform(new V2(ballX, ballY+10), 0);

i had set the ballX ballY vars earlier in the script like so :
var ballX = wrld.bl.bdy.GetPosition().x; /// returns -0.6666666865348816
var ballY = wrld.bl.bdy.GetPosition().y; /// returns : 9.945833206176758

my problem is this,
after i call the SetTransform method, the ball moves to where i want it to go, BUT the ball is FROZEN,.
i cannot drag it, nor does it fall and react to gravity anymore.
Please can anyone assist me here, or know of a better way to do this?
i am not the greatest at physics for game development, but i am very well versed in oop, and as3.

Any and all assistance is greatly appreciated.
thanks.
shane.


Top
 Profile  
 
PostPosted: Thu Sep 01, 2011 6:52 pm 
Offline

Joined: Wed Aug 31, 2011 6:34 am
Posts: 3
well thanks to some more searching, gojohnnygo's post further up in the forums, i have figured it out like this...

wrld.bl.bdy.SetType(0);//make static
wrld.bl.x = -40;
wrld.bl.y = 590
wrld.bl.syncTransform();
wrld.bl.bdy.SetType(2);//make dynamic

and all is well. ball gets teleported back to where i want it, and drops right back in place.
my apologies for the "duplicate" question, when the answer was already around.... and i had even read that post earlier, but i hadn't understood it, due to the fact that originally i was not working with the body, but the shape instead....

Cheers.
shane.


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

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


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