Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (580) Games in Android Showcase (162) games submitted by our members Games in WIP (632) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Phys2D joint  (Read 1570 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

You cannot reply to this message, because it is very, very old.

 Waterwolf (20 views) 2015-05-20 15:01:45 chrislo27 (24 views) 2015-05-20 03:42:21 BurntPizza (58 views) 2015-05-10 15:53:18 FrozenShade (44 views) 2015-05-07 09:11:21 TheLopais (207 views) 2015-05-06 13:36:48 TheLopais (191 views) 2015-05-06 13:35:14 TheLopais (198 views) 2015-05-06 13:33:39 TheLopais (214 views) 2015-05-06 13:32:48 TheLopais (214 views) 2015-05-06 13:31:28 ClaasJG (236 views) 2015-04-30 20:33:25
 Spasi 31x BurntPizza 16x theagentd 14x DavidBVal 13x ra4king 12x EgonOlsen 11x Husk 9x KevinWorkman 9x scanevaro 8x princec 8x KaiHH 7x Riven 6x opiop65 6x revers 6x SauronWatchesYou 5x Drenius 5x
 List of Learning Resources2015-05-05 10:20:32How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00
 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