PDA

View Full Version : Bouncing Balls inside of a Movie Clip Circle



dutchoh1
December 4th, 2008, 02:10 PM
I have been playing with multiple different AS3 bouncing ball tutorials in an effort to have the balls bounce inside of a circle or other shape instead of just the stage.

Does anyone have any ideas of things to try?

I have a pretty good grip on the physics part, I am just trying to figure out how to make the balls stay inside of a certain boundary. Most of the tutes I have seen discuss top, bottom, left, and right....They do not touch on shapes that are not perfectly square.

Any ideas or direction would be greatly appreciated!
Thanks Brian

creatify
December 4th, 2008, 03:46 PM
basically, the collision detection use to check boundries within a square works the same for a circle, except, you use trajectory direction and then the radius of the your circle. Granted, it's not one line of code. Your best bet is to get this book, it contains all the math to make this happen: see here. (http://www.amazon.com/Foundation-Actionscript-3-0-Animation-Making/dp/1590597915/ref=sr_1_1?ie=UTF8&qid=1228423421&sr=8-1)

for irregular shapes, it gets quite a bit tricker. Might find something useful here (http://www.gskinner.com/blog/archives/2005/10/source_code_sha.html) even though it's as2. If you dig around on that blog, I believe there is an as3 version but I couldn't find it. hope this helps.

scottc
December 4th, 2008, 06:11 PM
basically, the collision detection use to check boundries within a square works the same for a circle, except, you use trajectory direction and then the radius of the your circle.

http://www.tonypa.pri.ee/vectors/tut09.html

dutchoh1
December 8th, 2008, 09:16 AM
thanks so much, this really helps out alot!