Now you see why I get all confused…
I have this in the utility.lua
local M = {} function M.move (obj) transition.to(obj, {time=1000, delay=1000, x=1000, y=700}) end function M.glow (obj) transition.to(obj, {time=100, xScale=1.5, yScale=1.5}) transition.to(obj, {time=100, delay=500, xScale=1, yScale=1}) end return M
I just added another function that I use in my game (notice that it’s the same as the cat test.
I’m passing an object (obj)
and in my page1 I have this
glowCoin = display.newImage ("glowCoin.png") glowCoin.x = display.contentWidth / 2 - 120 glowCoin.y = 40 glowCoin.xScale = 1.2 glowCoin.yScale = 1.2 --function glow () --transition.to(glowCoin, {time=100, xScale=1.5, yScale=1.5}) --transition.to(glowCoin, {time=100, delay=500, xScale=1, yScale=1}) --end utility.glow(glowCoin) local cat = display.newImage ("granja/ardilla.png") cat.x = 100 cat.y = 100 utility.move(cat)
In the comments is the function I “move” to utility.lua
To me it’s exactly the same, unless I made a mistake
When I run the code…
The .move works!
the .glow DOESN’T
Why?
--------------5 minutes later-------------
I notice that I have “local” in cat
and no “local” in glow
So I add “local” in glow to make it the same
I run the code…
Errors------
I have in another line before, some transition
if lamp.x == 87 then transition.to(lamp, {time=100, x=87, y=455}) lamp:removeEventListener ("touch", lampTouch) audio.play(win) coinLampara.isVisible = true transition.to(coinLampara, {time=1000, x=glowCoin.x, y=40, onComplete=glow}) addToScore(10) end
Where I use the function “glow” onComplete.
So what do I do?
Do I just type this…
transition.to(coinLampara, {time=1000, x=glowCoin.x, y=40, onComplete=utility.glow(glowCoin)})
?