Bounce, Collide, Bounce again?

Hi!

Flash 8 Actionscript question:

I’m trying to figure out how to get 2 (or more) movie clips to bounce off each other and it’s a bit frustrating since I’m just learning HitTest etc.

What I have:

  • I have 2 movie clips, a circle and a square.
  • each movie clip has actionscript for the “falling” gravity to work.
  • each movie clip has a button in it with actionscript for the dragging and releasing etc.
  • When the movie loads, the circle and square drop from the top of the stage and bounce (using gravity etc).
  • You can drag and “throw each” object and it will bounce off the sides and bottom of the stage.

What I’m trying to do:

  1. I’d like the circle and square to bounce off each other when they collide just like they bounce off the sides of the stage (right now they bounce behind or in front of eachother based on their layer depths).
  2. Also, but less important, I’d like them to bounce off the top of the stage too instead of flying up and out.

Questions:

  • How do I make this work? I’ve seen many examples using HitTest etc on instances of one movieclip, but my movie clips need to be different since they will be turned into separate objects/graphics later (if that makes sense). Is this still a HitTest solution? I don’t think so since I’m not really using HitTest to begin with? I’ve tried incorporating code from some of those examples, but it just doesn’t work.

I’ve attached 2 files - one in Flash 8 format, and another in Flash mx2004 format so hopefully someone can open one of them, take a look at the code and give me some help.

I appreciate it :slight_smile:

Peace,

Hondo311

go to google type in simple gravity and there will be a tutorial usually the same one for the first like 10 links check that out it shows you how to do realistic gravity and bouncing off walls and such maybe you can mod the code to include another object.

[QUOTE=cooldude88;2326237]go to google type in simple gravity and there will be a tutorial usually the same one for the first like 10 links check that out it shows you how to do realistic gravity and bouncing off walls and such maybe you can mod the code to include another object.[/QUOTE]

Hey there cooldude88,

Thanks! I have searched and looked at a LOT of tutorials on gravity . . . my file already has the gravity part down, and the clips bounce off the walls fine . . . they just don’t bounce off eachother (arrgh heheh :slight_smile:

I’ve been searching for every term I can think of (at the Kirupa forums too) but just haven’t found what I need . . . I hope one of the kind and most brilliant actionscript gurus here can lend a hand to a sinking flash-designer! heheh.

Hondo311

Annnnnnnnnnnnnyone???

Hondo311