Hello,
i have a question: how to get x and y coordinates from a table randomly? i tried this, but its get me an error for y property
1 2 3 4 5 6 7 8 9 10 11 12 13 | local coords = { {x=38,y=265}, {x=38,y=345}, {x=38,y=425} } local function return_random() local ranX, ranY for i=1, math.random(1,#coords) do ranX,ranY = coords[i] end return ranX,ranY end local a1 = display.newText ("TEXT", 0,0, native.systemFont, 16) a1.x,a1.y = return_random() |
Hey darkconsoles,
I would make your return_random function look like this:
1 2 3 4 | local function return_random() local r = math.random(1,#coords) return coords[r].x, coords[r].y end |
thanks firemaple)
views:1401 update:2011/11/14 9:16:56