Hi,
I am still working on an elastic rope which can be stretched by touch events. From
different sources, I've read that you need the Box2D's Rope and Distance Joints
(and Mouse Joint). In Gideros there is no Rope Joint. Is there an alternative?
Is there probably some example code to check? I've found it quiet complicated
to create a elastic rope. I have been experimented with the Chain demo example.
Regards and thanks in advance,
Marc
Comments
Some of the physics are useful but this is not what I am looking for. I
want to create an elastic rope (like you can see in Angry birds on the
catapult and in Cut the Rope). Here they will use "Rope Joints". See:
http://www.raywenderlich.com/14793/how-to-make-a-game-like-cut-the-rope-part-1
I don't know if you can do the same with distance joints. I think that Gideros
will not support Rope Joints.
Thanks and regards,
Marc
But as I have mentioned before (at least I think I have), you can use Wheel joint.
Here is a quick video for my experiment:
http://www.screenr.com/cxd7
Is this any similar to what you wanted to achieve?
I will try to post a blog post on this, just wanted to make sure that's what you wanted
Also nice one to put on AppCodingEasy. Do you have the sample code
for me?
Thanks a lot,
Marc
Made it in kind of haste, so if anything seems wrong, just post here
Just experiment with dampening and frequencies to achieve desired result
Likes: marbolec
Marc
target landing position of the launched object like you showed me via
the iforce2d link in a previous mail?
I have switched X and Y to get the rope horizontal. I am also looking
to move the rope objects and bodies more closer to each other (I use
small rectangles instead of balls and edgeShapes). In that case I think
that you can't pull the shooting object through the rope and get a
more straight line without holes. I am still experimenting with damping
ratios and frequencies. It's still not really clear to me how to use these
parameters.
Regards,
Marc
you can give some advice. Isn't it better to use the slingshot example to model my
idea? May be it's then possible to model a chain (like your example) around the object
you want to launch. This chain is only following your object movement.
To give you an idea what I like to make, here is a simplified drawing.
Regards,
Marc
This way you could also restrict the dragging radius of your throwable object, so it won't get through the chain links from too powerful dragging
Marc
by using your Slingshot example. It works great, also the physics. To wrap a
chain/rope around the object to make a visual elastic rope when dragging,
you need another joint I think. Are you allowed to make multiple joints between
different objects (the rope, finger, mouse) and the shooting object? In my game
I like to place the finger anywhere on the screen and move the arm/hand, the
rope and the shooting simultaniously. When releasing at a certain point I will
release the object. The placement of the finger anywhere on the screen and
shooting the object like the slingshot is already working.
By the way, I think that I asked this before, but do you have already a game
released I can check? With your knowledge you could make great games.
Regards,
Marc
Yes you can attach how many joints you want to the object.
Here you actually have two options:
The easy way is to use the mousejoint/slingshot on the object you want to throw, and let the chain wrap it around by itself (by simply attaching both ends of the chain to the dummy ground object, as shown in mine example)
The hard way is to attach both throwable object and the center of the chain to the mouse joint, but apply slingshot only to throwable object. I don't know if it's better or if needed at all, you just can try and see how it works out.
And there is much more than a box2d knowledge needed to make great games, I'm still on my way learning
But here is my first project created with Gideros: http://jenots.com/mashballs
created a simple (times tables) game (Super) Kruistafels with Objective-C
and Cocoa only.
http://crappdesign.com/en/apps
Now it's time for more graphical fun.
Marc
a dummy mouse body instead of for example "mouseBody"?
Marc
well it might as well be air
I am busy to work you examples out. First I will make bodies and joints
to move the arm and object when moving your finger anywhere on the
screen. Then, the challenge to make al the rope/chain bodies around
the object. I think that I will use small rectangle bodies which will overlap
each other. I will let you know when there is positive progress.
Marc
Likes: ar2rsawseen
anywhere on the screen there must be a connection to the hand and the
object (see picture above). The hand and the yellow object must be connected
to each other if they are one object/body. With the Weld joint, I will not work
as expected. Al the bodies have been created before the following code.
what actually happens? what exactly does not work?
will follow. The arm will stay in place. When I release the mouse the
arm will fall down. Strange because I gave the arm 0 density. I have the
debugDraw activated. When I use the the Distance joint I will follow but
not as one object. At a certain point the arm will turn around the object.
This is what a distance joint does, and not created for this job I think.
In the onMouseMove I do:
The object will shoot away as expected.
In the onEnterFrame I will do the following:
a physics/Lua guru I can help you out. :>
Marc
Problem is that you're sometimes looking for the complex way while the
solution could be much simpler.
Thanks again. Where are you from by the way? I am from the Netherlands.
Regards,
Marc
Great news.
I am still experimenting with the WheelJoint. What I've found very difficult
(and still) is to set the values of the: setSpringFrequencyHz and
setSpringDampingRatio. I do not understand what these exactly do. Is
there any documentation on this? Also varying parameters like Density is
still something to learn. You need to get feeling with these physics terms.
Regards,
Marc
But from initial experiments, the higher frequency the harder it is to stretch the rope.
Dampening on the other hand reduces the power needed to stretch it.
But if you set high frequency and low dampening the physics will become jigged, so frequency and dampening should be in some sort of relative ratio. You need to increase them both in some specific proportion to get a taut rope.
hand. I tried the wheelJoint. I created small chain elements (4x2 pixel
rectangles) from left to right. Before the the object will be launched I've
set the gravity to zero so the object will stay in place. When I create the
chain of elements with the wheelJoint, the object will flow up. Is there a
way to bend the chain nicely round the object by setting the frequency,
damping and density. Not a quiet easy task I think.
Regards,
Marc
Really interested in how it looks for now, can you post a screencast or screenshot of a working mechanism?