Box2D Forums

It is currently Thu May 23, 2013 6:49 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Attaching userData
PostPosted: Mon Feb 07, 2011 2:26 pm 
Offline

Joined: Mon Feb 07, 2011 2:00 pm
Posts: 1
hi, im new to all this but thought i'd ask. how to attach sprites to bodies in alchemy port?

can i do something like:
Code:
...
bodyDef.userData= new sprite();
...
body= world.CreateBody(bodyDef);
body.CreateFixture(fixtureDef);
addChild(bodyDef.userData);

this won't link the sprite and body. am i doing something wrong? or do i have to update sprite position by calling a function?

thanks!


Top
 Profile  
 
 Post subject: Re: Attaching userData
PostPosted: Mon Feb 07, 2011 4:57 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
You'll have to update the sprite manually. This is the core concept of WCK. A MovieClip is assigned to the userData, then after each timestep it updates the position and rotation of the MC based off the Box2D properties.


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 0 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