Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (757) Games in Android Showcase (229) games submitted by our members Games in WIP (844) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Phys2D joint  (Read 2349 times) 0 Members and 1 Guest are viewing this topic.
Cutter

Senior Newbie

 « Posted 2007-08-20 19:58:19 »

Does any one have any idea on how I can have 2 shapes stick together so that if the object behind (a box) moves it will push the other (a circle) with their positions relative to eachother staying the same, at the moment I have tried using joints but the circle keeps rotating around the square when it moves.

NB:  the world is a  top down view, like the pool table demo

Thanks
lhkbob

JGO Knight

Medals: 32

 « Reply #1 - Posted 2007-08-21 05:13:28 »

You should be a little more specific about what needs to be accomplished.  For example, do you need the sphere to stay touching the box when the box is pulled away, or have the sphere stop moving when the box stops as well.  I would think a joint should accomplish this, maybe you just need stiffer joint parameters or a different type.  Or you could try composite geometries acting as one physical object (I'm not sure if Phys2D can handle this, though, I never used it).

Cutter

Senior Newbie

 « Reply #2 - Posted 2007-08-21 09:32:44 »

I need them to act as though they were glued together with super glue as in to act as a single body. So whatever the box does the circle will do.

Just an after thought. I suspect the solution would be to add some forces to counter those making it move around but thinking about physics is not a good idea for me as a few attempts I have made will prove. Any thoughts?
Bonbon-Chan

JGO Coder

Medals: 12

 « Reply #3 - Posted 2007-08-21 12:27:02 »

You mean something like :

 1  2  3  4  5  6  7  8  9 scare = new Body( new Box(2*r,2*r), massScare );  // Create the scare (position 0,0)circle = new Body(new Circle(r), massCircle);  // Create the circlecircle.setPosition( 2*r ,  0.0 ); // Put the circle on the scarejoint  = new FixedJoint(scare,circle);   // Attach the scare and the circle (fixed length and angle ?)world.add(scare); // Add everything to the worldworld.add(circle);world.add(joint);

I had use something like that to joint several spheres (to apply forces on the side of a circle).
CommanderKeith
 « Reply #4 - Posted 2007-08-22 08:47:18 »

Hi,

You just need to use a FixedJoint, it's easy.  The only problem that I found with them is that if you the centres of two shapes are on the same point and you try to connect them with a fixed joint then they will not be fixed when you rotate one of them - they will spin around each other.  The will however move up and down and across with each other.

Let us know if you get the FixedJoint working!
Keith

Cutter

Senior Newbie

 « Reply #5 - Posted 2007-08-28 23:17:34 »

The results with the fixed joint are better than what I had before but still not perfect (namely vibration which can be annoying when the screen is scrolling), I'll try and play around with things over the next few days and tell you guys how it worked out. Thanks for the help so far.
Pages: [1]
 ignore  |  Print

 EgonOlsen (78 views) 2018-06-10 19:43:48 EgonOlsen (58 views) 2018-06-10 19:43:44 EgonOlsen (78 views) 2018-06-10 19:43:20 DesertCoockie (260 views) 2018-05-13 18:23:11 nelsongames (158 views) 2018-04-24 18:15:36 nelsongames (157 views) 2018-04-24 18:14:32 ivj94 (898 views) 2018-03-24 14:47:39 ivj94 (162 views) 2018-03-24 14:46:31 ivj94 (811 views) 2018-03-24 14:43:53 Solater (175 views) 2018-03-17 05:04:08
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org