I need 2 methods that virtually do the same thing with different information. As the title suggests I'm using Box2D and iOS to make a game. These methods will be called each time step. Here are the method headers:
- (void) accelerateWithAngle:(float)angle body:(b2Body *)body speed:(float)speed rate:(float)rate;
With this, you should be able to create a nice acceleration on the b2Body given. A couple of notes:
- The Angle is in DEGREES. And should work like a normal protractor.
- The Body has a method called "GetUserData". WIth this method, you can retrieve the UIView attached to the b2Body if needed.
- The Speed is in Pixels. Therefore, you will need to convert it to meters. But a 20 second google search will tell you that there are roughly 3600 pixels per meter.
- The Rate is optional and should be tested for 0. (if 0, the rate isn't going to be applied). If the rate is not 0, then you should use this value to increase the b2body's speed by.
The next method is the same as the previous only, instead of a angle, takes a CGPoint. The b2body should accelerate to that point, and slow down when halfway to that point. like in this animation: [url removed, login to view] Here is the method header for this method:
- (void) accelerateWithAngle:(CGPoint)position body:(b2Body *)body speed:(float)speed rate:(float)rate;
The same notes apply. Please make user you reply with "I love sexy b2Body's". So I know you read this.