views:

26

answers:

2

I'm trying to stack particles on top of each other, almost as if sand is piling up in an hour glass.

I don't want a pile, I want it to kind of stack from left to right. Ideally, they would be flowing in from the top at an incremented pace, like one every couple of seconds. Right now, they just kind of pop in.

I'm stuck on a bug that starts placing the circles' coords at 0,0. It happens randomly, depending on the size and current count of circles. I can't tell what the problem is and I wish I could just find an API for something of this sort that I could use for right now. I'm in a huge pinch and any help or ideas are greatly appreciated!

http://jevinkones.com/circles/

+1  A: 

Either you are propagating the x-y coordinated incorrectly as you progress, or there is some sort of overflow happening when the coordinates exceed the canvas size, and they are defaulting to (0,0).

This is a good candidate for your ActionScript debugger. Every time you instantiate a circle, you can put a break point on the assignment for the circles x and y position. Then, when you notice it is a zero you can look at the call stack and figure out how this stuff was being called.

If you're unfamiliar with your debugger, you could alert out the coordinates of every circle you are stacking. The debugger seems like the correct tool for this job.

I hope that's helpful!

-Brian J. Stinar-

Brian Stinar
Hi Brian,Thanks for your reply. I've got the x,y tracing out to the output window, and I can see where things are going wrong. I'm just not sure what I need to change in my logic to accommodate the result I need.The x,y of a new circle are determined by the x,y of the last circle(s) and their radius (to calculate distance). On a new row it is starting at the left and tries to snug up to the previous row's circles by calculating the radius of the new circle with that of the lower circles. If overlap is detected it uses another circle to see if the calculated x,y is suitable for placement.
jevinkones
Can you post your implementation? There is definitely a problem with your overlap detection - since the circles being stacked at (0,0) are overlapping. Maybe this problem is related to the actual placement at (0,0)...?
Brian Stinar
A: 

The problem happens at the same point , when the circles fails to go to the left on the third or fourth row. It looks like your calculation to set the circle back to the left is wrong.

As soon as a circle overlaps the other, the remaining circles don't get a correct value . This may be actually a flaw in your logic , the circles are too interdependent so one error leads to everything failing.

Also you can see that each time a new row is created , the circles are added further to the right side of the screen , so with your swf size , you'd have at the most 5 or 6 rows max with a large white space on the left.

instead of finding the "bug" , i'd suggest to try & think of another approach, maybe simplify the placement of the circles , remove the random elements. work out a way to fill the space evenly , then add the random elements back

PatrickS