So I have built a system I add a button to a scroll box for every entity in my game, now when this button is spawned it loads the information of the individual, my issues is setting the rows and columns.
This is how i set the columns in theory every time one is added i add 1 to column then when columns = 3 i add 1 to row and reset columns so there would be 3 rows and 3 columns 9 things in total but…
Thank you it worked using the branch first then setting the column on the false Line, but me being an idiot I for got the basics of a integer the fact that they count 0 as a value so my text was instantly jumping the first space and was checking for 4 rows not 3 so I set the default value of my row and column to -1 to account for this. Thank you for your help
try setting column after the branch, instead of before.
usually, all code logic goes something like this:
Update state
BoundsCheck state
Render.
so you increment the integer, wrap it when it over flows the bounds, Then use that data for displaying stuff. if you use the data after moving, but before bounds checking, you get inconsistencies.
so most update logic should have math at the start, branches in the middle, then functions at the end.
or in other words, you have to finish processing data before you use it.
THANK THE MAKER! I was having a similar problem where my grid would move lower every time I accessed it. Setting my row variable to zero on exit fixed the issues.