We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › BoxWrap2d set ball position??
Page Index Toggle Pages: 1
BoxWrap2d set ball position???? (Read 1226 times)
BoxWrap2d set ball position????
Jun 25th, 2009, 1:24pm
 
Hi,

i'm trying to use BoxWrap2D in processing to
simulate a physical environment:

When people touch in a touchscreen table,
they can manipulate a previously created "ball"
in the finger's current possition, and set the next
position with moving finger.

With that ball, the people can apply colisions in other balls
(which exist independently of the touch of finger)

I'm very confusing with this lib (because i'm new in processing, Tongue),
and I do not see a method for set a new position for this "ball", like
a method "getPosition()"...

Thanks
Re: BoxWrap2d set ball position????
Reply #1 - Jun 25th, 2009, 4:49pm
 
check the documentation.

in the physics class you will see what you need.


Vec2 pos = physics.getPosition( body );

'pos' will have the 2d pos of the current 'body' object
Re: BoxWrap2d set ball position????
Reply #2 - Jun 26th, 2009, 1:47am
 
V, I think that gui was meaning a setPosition instead.
I am still new to BoxWrap2D, so I can't answer directly. I saw a number of demos allowing to drag a shape by making a joint between the shape and the position of the mouse. I have also seen a MouseJoint was requested (exists in Box2D, not yet (?) in JBox2D).
Re: BoxWrap2d set ball position????
Reply #3 - Jun 26th, 2009, 2:02am
 
still i think you should read docs. its a good thing. it will prepare you for the future..


you have Body class which you can find at the box2d docs.

check Body's setXForm( vec2, angle );

to make a mousejoint set a joint or just add a velocity vector (Body.setLinearVelocity) to the object in the direction of your finger. make it slow or fast as you need.

have fun
Page Index Toggle Pages: 1