Can anyone help me make a pinball game? I need help making a ball bounce and come off objects at the correct angle.
Printable View
Can anyone help me make a pinball game? I need help making a ball bounce and come off objects at the correct angle.
That is one really big project. I suggest using a pre-built physics engine.
Flade is probbably the only one you can use since most are in AS 3.0.
for the hittest detection in a ball
you must
ps. the point in the ball must be in the center
detect=(floor.hittest(ball._x+ball.width*0.5,ball. _y,true))||(floor.hittest(ball._x-ball.width*0.5,ball._y,true))||(floor.hittest(ball ._y+ball.height*0.5,ball._x,true))||(floor.hittest (ball._y-ball.height*0.5,ball._x,true))
if(detect){
//invert speeds of the ball
}
of course floor is the object
ps- don`t forget the ball always goes down
What if the floor is angled and the ball falls onto it it shouldnt bounce back up it should bounce the angle oppisit of the angle between its motion and the tangent of the surface