Jump to content


Ball bounce help, need to change angles.


  • You cannot reply to this topic
1 reply to this topic

#1 ScottY

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 18 June 2007 - 06:52 PM

Hey guys, i've been using Flash for a while, but i haven't really looked into the ActionScript side of things, so i decided to do some more in depth stuff, i can do the simple stuff, but for animations etc i usually use tweens and crap.

Anyway getting to the point, i used a tutorial to help me learn some ActionScript, we aren't talking about normal ActionScript, im using Flash Lite, trying to develop a game for my N95.

The tutorial i used taught me the basics and it all works fine, all ActionScript, BUT i have the ball bouncing off the 'paddle' at the same continuous angle, or the exact opposite, the only time the angle changes is when the game starts where i have the start set to a random number. But on my paddle i want the ball to bounce off at different angles, but i ask how do i do that?!/ lol.

I belive this bit is the section that needs sorting :
This is run as soon as the game is started.
function onBallMove():Void
{
	// Move the ball
	ball_mc._x += (horizontalSpeed);
	ball_mc._y += (verticalSpeed);
of course there is more code to go with it but i thought posting it all was a bit too much, well 230 lines might not be but ah well...

The horizontal and vertical speeds are both set to generate random numbers (either 1, 2, 3 or 4), so when the game starts it moves in one of the possible combinations from that, but the same angle is kept throughout until the game is relaunched, haven't managed to get a restart function working yet...

So as you can see i have no idea what so ever :D hoping someone can help. If you need ther rest of the actions are uploaded in the attached .txt file. IF you want the .fla ask and you will receive. You can see my BETA release, at bog standard level here LINK.

Cheers guys.

{edit} forgot to say its Flash Lite 2.0

Attached Files


Edited by ScottY, 18 June 2007 - 06:54 PM.


#2 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 18 June 2007 - 08:26 PM

Not too sure what you are asking to do. That game works just like any block breaking game does. Your angle inversions are correct. The only thing you need to fix is when the ball makes contact with something, rather than just inverting the speed on that axis, you also need to reposition the ball so it is not touching the object any more. If you don't do this, you'll get some jitters while it gets stuck on an object for a bit. This happened to me a few times.

If you want a different angle, on a bounce, just change the vertical or horizontal speed. It might not look right if you start doing that tho.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users