I need a math wiz to solve this

I have a math problem I've been trying to solve. I don't even know if it is possible and if it is I don't have the math skills to solve it.

I am trying to spawn a grid of cells with multiple spawners and each cell needs to store its own row and column number in self attributes when it is spawned. I am trying to achieve this by using the X and Y axis positions of each spawned cell. This can be done with one spawner but the grid is 52 rows x 17 columns and spawning one at a time is very slow so I want to try it with multiple spawners. I also would like to spawn the cells with as few rules as possible to make it as fast as possible.

The row number is easy all the cells are the same height so a little formula will Identify its row number and pass it to a self attribute "(Start Position (1130) - self.Position.Y (1110)/self.Size.Height (20)". When the first cell in the column is spawned the result is 1 when the next cell is spawned it will equal 2 and so on. This won't work for the column numbers because the columns widths vary.

I have been trying to work something out in the attached spreadsheet. In;
Row 1 are the column numbers
Row 2 is the cell/column width
Row 3 is the X axis position for the cells in that column. The first column starts 10 pixels in from the edge of the screen so it's Pos X = 10 + (column width / 2)
Row 4 & 5 are my attempt to mathematically find the column number by its X position. A poor effort but about my level of math

I know all the x positions but passing them to a cell would require a lot of rules and attributes. I was hoping to use a formula in a Change Attribute action like the one for the rows.

Can someone say if this is even possible, have an idea how it can be done or a better way to do it? Any help would be greatly appreciated.

Comments

  • colandercolander Member Posts: 1,610
    I found a solution using a table and the new tableSearch() function to look up the self.Position.X value in the table and return the column number of the table.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Not sure if this helps. This does not use the nightly builds, though it would be a little easier if it did.
  • colandercolander Member Posts: 1,610
    @CodeMonkey thanks, that's a great it works well. I changed it to lay out the cells in a grid top down 50 rows x 17 columns. Also changed the Project platform and added zoom. It takes 30 seconds to load and lay out the grid on an iPad 1 and 40 seconds on an iPhone 4.

    This only takes 6 seconds in the Creator and it is the best way to make changes to the layout while I develop the app but I would like it to load faster when I release it. Could load times be reduced if I laid out the 850 instances/cells by hand so they don't need to be spawned?

    The zoom button jumps around quite a bit while it is zooming in and out. I set it up as per one of tshirtbooths videos but I think the interpolate behaviour must run at different speeds. Is there anyway to fix this?


Sign In or Register to comment.