Increase speed of a body

Hi!

I'm new in this forums, my name is Federico, i'm from Uruguay.
I'm currently working on an advergame, the idea was to make a game like Tiny Wings. In this games there's no bird, there are bikes and each bike has different speeds (You can buy a faster bike with in-game coins) that helps you to reach the end of each level. The final level has more checkpoints and its longer than the first one (Obviously he).

So, my bike is a b2body. The bikes init speed is 50, and max speed is 80, these are the settings of the body:

Code: Select all

_fixtDef = new b2FixtureDef();
_fixtDef.density=1;
_fixtDef.friction=3;
_fixtDef.restitution=0.1;
_fixtDef.filter.groupIndex=-1;

_bodyDef = new b2BodyDef();
_bodyDef.type=b2Body.b2_dynamicBody;
_bodyDef.position.Set(380/Terrain.worldScale,487/Terrain.worldScale);
_bodyDef.linearDamping = 0.1;
_bodyDef.userData = new Object();


So, now, i'm applying different speeds to each bike doing this:

Code: Select all

var bikeStatSpeed:int = (MenuState.selectedRider).stats.vel * 80;
// MenuState.selectedRider.stats.vel it's an int between 1 and 12 or something like that
bikeSpeed = bikeStatSpeed;
maxBikeSpeed = bikeSpeed + 60;

When i press the "RIGHT" key i have this:

Code: Select all

_rider.ApplyTorque( bikeSpeed );

And finally i have a function that increase that speed. I'm calling this function when you dodge the obstacles on the screen (You have to press 'space'):

Code: Select all

public function addVelocity():void
{
if( bikeSpeed <= maxBikeSpeed ) bikeSpeed  = 10;
}

The result? All bikes are getting the same speed, i think that it is no increasing or something like that, the terrain it's similar to the one in Tiny Wings (I read an Emanuelle Feronato's tutorial to do it).
How can i do the bikes increase their speed?

Thanks in advance,
Regards.

Original thread: https://box2d.org/forum/viewtopic.php?t=9340