Basically, I want balls to come from above, but I want to create an image showing the location of the incoming ball BEFORE it shows up.
So, I decided to create these two functions: newBall and spawnBall.
If I try to call the function “spawnBall” after two seconds with the delay as it is, the delay doesn’t occur and the ball is spawned imediately.
However, if I remove the “spawnBall” parameter - and use a fixed value in the function, so it looks like this:
[lua]timer.performWithDelay(2000, spawnBall, 1)[/lua]
It works out fine.
Is this a bug?
What can I do to avoid this, and how do I report it?
Thanks in advance!!! [import]uid: 11130 topic_id: 3698 reply_id: 303698[/import]
Method two seems cleaner and more like what I’m used to do, but I still don’t understand it as well
EDIT:
I mean… writing a function in there… Are we allowed to do that?! [import]uid: 11130 topic_id: 3698 reply_id: 11261[/import]
the braces creates a table/object (their the core fundamentals of lua structures)
the :timer means that object responds to the timer event
anyway i don’t think what i did there should have worked for you. maybe you’ve got a global item somewhere that it’s using which may mess things up if 2 things try and use it… don’t know without seeing your code. if you run it in a self contained file it just comes out as “nil”
however this works and is simpler
[lua]local function spawnBall(event)
print("spawnBall: "… event.source.something)
end
local function newBall(someVal)
local randomPosition = 100 + math.random(200)
print("newBall: "…randomPosition)
local t2 = timer.performWithDelay(2000, spawnBall, 1)
t2.something = someVal…", "…randomPosition
I checked my code and I’m using everything as local so far. If I find anything I’ll post it here.
I still gotta learn a lot of LUA and Corona to understand the events and braces used in the SDK. I’ve been working with this for less than a week now, with little experience in programming. [import]uid: 11130 topic_id: 3698 reply_id: 11266[/import]