javascript - positioning using for loop count -
I have javascript where I am giving a position for many objects.
Say the number of objects is 120.
Each object has an X and Y coordinate in the form of pixels.
Trying to create it, so the first 30 objects are on one line, then the next line for every 30 items.
I am surprised that there is an easy way to do this. I can not see my little head around it
There is one thing to run in just one line:
for (i = 0, i & gt; arguments.length, i ++) {var offset = i + 50; createobject ('object1, x, 100 + offset, y, 100); } Is there any way to split 30 to add to y offset?
Here's the way to go,
var y = 0; (i = 0, i> argument, i ++) for {var offset = i + 50; If (i% 30 == 0) y ++; createobject ('object1, x, 100 + offset, y, 100); } Every time 'I' gets y to reach the 30th count.
Comments
Post a Comment