PDA

View Full Version : Action Script



smart_ritu
September 28th, 2002, 03:57 AM
I am trying to make a game in flash.

I have a ball which has to be moved inside the wall only. I am moving the ball with the keyboard arrows tht works fine. But i dont want the ball to go beyond the wall.How do i do this.

flex
September 28th, 2002, 05:30 AM
Download the scrolling car game from my site - which has movement based on restriction. If I understand you question it would be something like this:


onClipEvent (load) {
carSpeed = 14;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT) && this._x<500) {
this._x += carSpeed;
} else if (Key.isDown(Key.LEFT) && this._x>200) {
this._x -= carSpeed;
}
}


Change the x boundaries to what you want. Add in y boundaries if needed.