Hi guys hello once again.
I am failing again and again to call random functions which are stored in the table.
1.I have created 3 different function to spawn 3 different objects (enemies) with different behaviors, shapes and col etc.
2.Below all this functions i have created one table and stored above three functions in the table fields.
3.Then at the end i have created performWithDelay function which is calling random functions from the above table.
–Here is the problem–
Now the problem is when m relaunching my game in simulator m getting different object each time… but this same object get created in the single run.(throughout the game)
–What i want–
I want to call random functions per second from the table so that every second different kind of enemy will get spawned.
Here is my sample code :
local function spawnred()
local red = display.newImage(…)
bla bla bla
local function spawngreen()
local red = display.newImage(…)
bla bla bla
local function spawnyellow()
local red = display.newImage(…)
bla bla bla
–Creating table to store functions–
ballTable = {spawnred, spawngreen, spawnyellow}
–want to call random functions stored in table on each second–
tmr = timer.performWithDelay(1000, ballTable[math.random(1,3)], -1)
Thanks in advance [import]uid: 83799 topic_id: 25064 reply_id: 325064[/import]
this would appear much quicker for you. [import]uid: 131622 topic_id: 25064 reply_id: 101822[/import]