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 & HelpPrograms › I have a question about BoxWrap2D
Page Index Toggle Pages: 1
I have a question about BoxWrap2D (Read 892 times)
I have a question about BoxWrap2D
Oct 7th, 2009, 11:18am
 
hello, I'm studying about BoxWrap2D.

but I have a qeustion.
I'd like to select circles with mouse and drag it.
here coding.
--------------------------------------------------------------------------------
-
import org.jbox2d.testbed.*;
import org.jbox2d.dynamics.contacts.*;
import org.jbox2d.p5.*;
import org.jbox2d.dynamics.*;
import org.jbox2d.common.*;
import org.jbox2d.collision.*;
import org.jbox2d.dynamics.joints.*;

// Physics things we must store
Physics physics;  
Body randomBod ;  

void setup() {
 size(640,480,P3D);
 frameRate(60);

 initScene();
}

void draw() {
 background(0);
}

void initScene() {
 physics = new Physics(this, width, height);
 physics.setDensity(1.0f);
 
 
  for(int i=0; i<10; i++){
   float x0 = random(0,width);
   float y0 = random(0,height);
   randomBod = physics.createCircle(x0, y0, random(5.0f,15f));
   Vec2 vel = new Vec2(random(-30.0f,30.0f),random(-30.0f,30.0f));
   randomBod.setLinearVelocity(vel);
 }
}
------------------------------------------------------------------------------
How can I select a circle and drag or throw it?
thank you  Smiley
Re: I have a question about BoxWrap2D
Reply #1 - Oct 8th, 2009, 1:48am
 
You need to do a MouseJoint. You are lucky, I experimented with the feature and the resulting code might get you started.

I also take the opportunity to plug my JBox2D with BoxWrap2D Tutorial... Not finished, but perhaps it can help you.
Re: I have a question about BoxWrap2D
Reply #2 - Oct 12th, 2009, 8:09am
 
Thanks you for your help.
I looked your examples. I can do it now!
Thank you ver much Grin
Page Index Toggle Pages: 1