i am trying to make a pong game using only hittests and variables to set the constant x movement of the ball. the code for the paddles works fine but the code for the ball doesnt.
the problem is, when the ball hits the paddle, it works fine for one frame, and the ball looks as if to go up, but then it suddenly starts following its intial path.PLEASE HELP!!!
i know that the problem is very elementary but at the moment i cannot figure it out. btw i did not actually use onClipEvent(load)
i used enterFrame, just changed it for testing purposeds
what’s hapening is it sees the hit and does what’s in the if statement but then the if statement is no longer true so it goes back to what it was doing before. Would it be possible to put your hit test loop on the paddles and if it’s true then use
could you maybe elaorate on that sorcerer? im not exactly a flash wiz. i tried a little of what you said and put the hit test on the paddle. the ball moves the way i want it to now, only porblem is, the paddle moves with it…
I think i got it, I removed your original ball clip event and put it on an actions layer.
What I did:
You had it so that it would increase the x value by 14 and decrease the y value by 7 when it detected a hit. The problem was it would only do this when there was a hit and so the ball would go back to it’s orignal x += 14, y+= 7 unless the hit test was true.
What I did was first used the command
delete _root.ball.onEnterFrame
this clears any onEnterFrame commands on that MC
Then I assigned a new onEnterFrame command to the ball movie clip using
_root.ball.onEnterFrame = function(){
}
this executes whatever you put inside the function tags every frame. so on each hit test you will need to use delete to get rid of the previous function and then assign a new one to make it do what you want.