So I tried to give acceleration to the Speed
variable, but the variable is only given the value of ac
, and its not getting any higher/lower than that.
and my character is not moving… no scratch that, i accidentally set that frame as a tween. The speed is not getting larger or smaller
var Speed = 0
var mSpeed = 10
var ac = 1
//Speed control for basic movement
if (isKeyDown('a')){
if (Speed !== -mSpeed){
Speed -= ac;
} else if (Speed <= -mSpeed){
Speed = -mSpeed;
}
} else if (isKeyDown('d')){
if (Speed !== mSpeed){
Speed += ac;
} else if (Speed >= mSpeed){
Speed = mSpeed;
}
} else if (Speed !== 0 || isKeyDown('a'&&'d')){
if (Speed > 0){
Speed -= ac
} else if (Speed < 0){
Speed += ac
} else {
Speed = 0
}
}
this.x += Speed;
project.Speed_txt.setText(Speed)