PDA

View Full Version : Help with Programmatic Animation



absameen
February 27th, 2009, 07:26 AM
I've just learned the basics of programmatic animation in Actionscript 3.0 but I can't seem to think of the right solution for this problem.

Here is what I'm trying to do: A ball moves at a certain speed from the left of the screen to the right end. If there's a box in the way, it keeps bumping into it until the box breaks and it continues moving forward.

The box will have a set weight that will control how much it slides when it is bumped by the ball. The ball will be pushed back a bit when it bumps the box.

I have a very specific idea and all I need is a little help starting. How would you tackle this problem?

Sparda
February 27th, 2009, 07:42 AM
I'm new to AS3 but it sounds like a case for hitTest(). You would probably also use a loop to count how many times the ball is supposed to hit the box.

cbeech
February 27th, 2009, 10:46 AM
yes hitTest can be used here (although under AS3 you would use hitTestObject() ), unless you want to get a bit fancier and use some 'real' physics. if so you may be interested in looking into APE (http://www.cove.org/ape/index.htm), although one certainly can develop their own physics systems, but you'll need to be fairly adept with trig.

however, for what you're looking for here you can accomplish this with some very simple logic, and if you want the ball to 'pop' the box, then you will need to use a 'counter' so to speak as Sparta has stated. I've built a very quick basic example to get you going.

absameen
February 27th, 2009, 06:00 PM
Your example is exactly what I needed to start. Thank you!

cbeech
February 27th, 2009, 10:07 PM
you're welcome :) glad to help