Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Phys2D joint  (Read 1455 times)
0 Members and 1 Guest are viewing this topic.
Offline Cutter

Senior Newbie





« Posted 2007-08-20 21: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
Offline lhkbob

JGO Knight


Medals: 32



« Reply #1 - Posted 2007-08-21 07: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).

Offline Cutter

Senior Newbie





« Reply #2 - Posted 2007-08-21 11: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?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #3 - Posted 2007-08-21 14: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 circle
circle.setPosition( 2*r ,  0.0 ); // Put the circle on the scare

joint  = new FixedJoint(scare,circle);   // Attach the scare and the circle (fixed length and angle ?)

world.add(scare); // Add everything to the world
world.add(circle);
world.add(joint);


I had use something like that to joint several spheres (to apply forces on the side of a circle).
Offline CommanderKeith
« Reply #4 - Posted 2007-08-22 10: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

Offline Cutter

Senior Newbie





« Reply #5 - Posted 2007-08-29 01: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (8 views)
2014-07-30 21:08:39

Riven (20 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (29 views)
2014-07-23 21:07:15

Riven (30 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!