prolate cycloid body movement - cocos2d-iphone

How can I make a box2d body move along a prolate cycloid curve? I've searched extensively and haven't found anything leads. Below is an example of how the movement should look like. I would appreciate any help.

Related

How do you make a CCSprite appear as slanting like the star wars intro?

Skewing x and y coordinates doesn't give that kind of effect. Any ideas on how to achieve this kind of effect? I already use cccamera but there are no examples on how to properly implement this. This image btw is from cocos2dx tried the c++ code still didn't work
I feel I need to share this once and for all. So this is how camera works when you want a slanting ,45degree or pseudo3d view of your background :
First set your director to 3d perspective
[director_ setProjection:kCCDirectorProjection3D];
If you only want some of the sprites to appear this way then remember this
all nodes have camera (cocos2d v.3 doesn't seem to have it anymore I don't know why)
so you do this:
[mysprite.camera setEyeX:0 eyeY:-40 eyeZ:10];
[mysprite.camera setUpX:0 upY:0 upZ:1];
Play with the values that fits your need. Hope it will help others!

Having problems understanding body positioning in Box2d. Any pointers on how things work?

I'm struggling to learn and understand box2d. Here is my problem:
I'm trying to make a simple car, the car body looks like this for now:
Now I'm trying to add a wheel, I create the wheel body and I assume I'll link the wheel to the car body using a b2RevolutionJoint.
Until I get to that part I just want to be able to position the wheel in its place, so in relation to the bodyCar Body. How do I do this correctly?
What I've seen online is something like this:
bodyDef2.position.Set(axle2->GetWorldCenter().x + 1.3*cos(-M_PI/3), axle2->GetWorldCenter().y + 0.3*sin(-M_PI/3));
However, I don't understand the cos and sin parts of that expression.
What I'm trying to do is this:
backWheelDef.position = b2Vec2(carBody->GetWorldCenter().x - 20.0/PTM_RATIO,carBody->GetWorldCenter().y);
Since my carBody vertices definition looks like this:
b2Vec2 vertices[] = {
b2Vec2(100.0/PTM_RATIO,15.0/PTM_RATIO),
b2Vec2(100.0/PTM_RATIO,30.0/PTM_RATIO),
b2Vec2(50.0/PTM_RATIO,65.0/PTM_RATIO),
b2Vec2(20.0/PTM_RATIO,65.0/PTM_RATIO),
b2Vec2(0.0/PTM_RATIO,45.0/PTM_RATIO),
b2Vec2(0.0/PTM_RATIO,15.0/PTM_RATIO)
};
The result of the above way of positioning the wheel looks somehow correct (see below screenshot) but if you look at the above numbers it doesn't make much sense.
Since the carBody width is 100.0/PTM_RATIO I assume the GetWorldCenter().x would return a value equal to 50.0/PTM_RATIO.
So the wheel position would be after calculation at 30.0/PTM_RATIO, right?
Well, if you look at the result below the wheel x positioning seems to be at 20.0/PTM_RATIO.
Can someone please explain how things work with positioning bodies in relation to other bodies works in Box2D? Once I'm clear with these kind of things I'll move on to linking them using joints
Thanks a bunch!
LATER EDIT BASED ON iforce2d ANSWER:
Thank you iforce2d for answering and thank you for all the good insight you provide in the box2d world. What you're saying is perfectly true but this wasn't my question.
Once I've figured out that GetWorldCenter returns the center of gravity and GetPosition returns the position origin of the object it was easy to place my wheel exactly where I needed it to be in relationship to the carBody. Even though I still got the behaviour of it appearing under the body I knew this would be fixed once I add joints into equation.
Now I have another question that somehow relates to this positioning problem. Take a look at the image below:
Is this the right way my joints should look once I set their anchor points as below? I'm a little confused by them going from origin instead of them going from anchorPointA to anchorPointB
Thanks again!
You are placing the wheel inside the car body to begin with, so in the first two or three time steps the two bodies will move to correct the overlap. It probably happens so fast that you don't see it, but the tell-tale signs are there, namely the wheel being positioned exactly at the edge of the car, and the car body being rotated a tiny bit.
If you pause the simulation (just don't call Step) you should see the bodies where you expect to see them.
Once you add the joint, the default behavior is for the two joined bodies not to collide with each other, so you wont see this problem.

how to pin/stick a box2d body to the ground

How can I pin or stick a box2d body (circle or polygon shape) to the ground (body). Sorry if this sounds quite simple, I've not been able to find anything relevant on this. Please help.
Just use that body as a static body ..! And it wont move anywhere ..!
Or you can also create a weld joint between the body and the ground.

how to make a box2d body move along a Bezier curve/ arc path

I've searched extensively on how to make a Box2d body move along a Bezier curve or arc-like path with a start point, end point and possibly another control point. I know cocos2d objects can be moved around using ccBezier but how can it be done for Box2d bodies? Please help. Thanks in advance.
I have tried to move a box2d body using a curve (making a spider walk around an asteroid). I found that using SetTransform every frame worked, but it made the collision response in the engine fail.
I was able to find a much better solution by using prismatic joints. You create a joint starting at the position (p0) you want to start from and pointed towards the next waypoint (p1). Then you let the joint push the body from p0 to p1 using the motor. When the body gets very close to the next point, destroy the joint and form a new one for the next two points. The body will still have its velocity so the motion looks smooth.
I put a more complete post on this on Stack Overflow here.
Was this helpful?

How do I give a Box2d Kinematic body a predefined curved path

I'm new to using Box2d and really can't find a consistent answer to my question so please excuse me.
I'm writing a game for the iPhone -- who isn't these days -- and I'm using Cocos2d and Box2D. I have objects that move around in the game and I would like to give them a more of a curved path. From my studies I know that I should use body of type b2_kinematicBody which allows me to change the linear velocity every tick and keeps them from colliding with my other flying bodies. I do understand that if I know my current position (x,y) and my next position in the step (x1,y1) I would be able to compute the vector for velocity. Does anybody have a good way to give an object a defined curved path? I'm thinking it has to be some kind of parametric equation.
Take a look at bezier curves. After curve defenition you can compute the derivative (it's easy for bezier) and use it as a velocity for your body
OH whats the game called? sounds like a good one. have you looked into maybe just doing that in version 2.0