I am kind of toying with different things in Flash trying to get aquainted with coding and what not.I want to get to the point of making some simple games. I am having trouble coming up with something to make a ball accelerate. Here is what I have to just make the ball move and jump around.
onClipEvent(load){
var moveSpeed = 15;
var jumpPower = 30;
var grav = 4;
var ysp = 0;
var jump = false;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT) && _x<550-_width/2){
_xscale = 122;
_x += moveSpeed;
if(jump==false){
gotoAndStop(2);
}
}else if(Key.isDown(Key.LEFT) && _x>_width/2){
_xscale = -122;
_x -= moveSpeed;
if(jump==false){
gotoAndStop(2);
}
}else if(jump==false){
gotoAndStop(1);
}
if(Key.isDown(Key.UP) && jump==false){
gotoAndStop(3);
jump = true;
ysp = 0;
ground = _y;
}
if(jump==true){
_y = _y - jumpPower + ysp;
ysp += grav;
if(_y>ground){
_root.bounce_sound.start();
ysp = 0;
gotoAndStop(1);
_y = ground;
jump = false;
}
}
}
That works just fine, but its real bland. I need it to be able to accelerate when I hold down the button and deccelerate once I let go.