Box2D Forums

It is currently Sat May 25, 2013 1:16 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Jul 26, 2011 10:21 pm 
Offline

Joined: Mon Jul 25, 2011 9:58 am
Posts: 8
Interestingly my question is tangential to the previous post In that it deals with restring objects to an initial starting position. I'm approaching it differently from the previous poster: I'm defining a reset() method on each body that sets an initial starting coordinate. Trouble is, if you call super.create() prior to setting the position, the position is ignored. IE: just setting the .x and .y properties on the MovieClip doesn't have the desired effect.

Looking deeper, I realize that since I'm extending Circle, maybe I need to initialize its position by overriding shapes() and passing the V2 for its coordinates.

The real trouble comes when I try to roll my own dragging routine using the built-in MovieClip.startDrag(). I'm doing this because I want a very simple bounded drag operation that later applies a linearVelocity to the object and then wakes it up to let box2d do its thing. I suspect this would be quite complex if I tried to do it entirely within the box2d framework and its dragEnabled, whereas it's quite trivial using built-in MovieClip methods.

What to do? Setting active=false and awake=false ain't cutting the mustard here. How can I temporarily suspend all the great wck stuff so I can do my low-level stuff and then re-enable it so I can set it loose on the world? Our am I coming at this completely back asswards?


Top
 Profile  
 
PostPosted: Sat Jul 30, 2011 10:47 pm 
Offline

Joined: Mon May 23, 2011 9:41 am
Posts: 18
Try this:
Code:
Util.setPos(myObject, myObject.initialPos);
myObject.syncTransform();

myObject.initialPos represents the inital position of the object that you want to reset (it can be a Point).


Top
 Profile  
 
PostPosted: Sun Jul 31, 2011 8:06 pm 
Offline

Joined: Mon Jul 25, 2011 9:58 am
Posts: 8
@viqtor: awesome! Thanks a million.


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: Bing [Bot] 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