PDA

View Full Version : MovieClip positioning within a grid with a twist.



jarredbishop
November 1st, 2008, 11:27 PM
Hello, I need to lay out some MovieClips in the following pattern. Does anyone have an idea about how it's best to do this? I'll be using a for() loop to attach and position them. Thanks

http://static.jbd2.com/files/positioning.gif

theCodeBot
November 2nd, 2008, 08:28 AM
Hmm... I think it will work if you move the indexes around by a pattern. You want to go diagonal, I see, but if you look at it left-to-right and top-to-bottom, it starts at 1, tghen adds 1, then adds 2, then adds 3, and wraps to the next row, which starts at 1+2, then adds 3, then adds 4...

So the formula would say something like this (assuming you have your rows and columns set up as row/column 0-5 or whatever number)
number to add to grid location [x,y] would be 1+x+(thisrowvalues[x-1]?thisrowvalues[x-1]:0)+y, so you just would reorganize the array using that formula (pain in the butt, but... that would place them correctly!) The one that should be to the right of 12 in your picture would be determined as tile 16 by this formula, and would fit correctly in that grid.