It has so many things, that I need to be very patience.
I guess I had to re-start the app.
I never did that before.
But now with the same code it’s working, when I call the function on complete I have this
onComplete=utility.glow(glowCoin)})
and it works!!!
Now that it’s to move 1 object – so I pass the object like this
–function M.glow (obj)
so inside the parenthesis I pass an “obj”
but what about if I have many objects to move or to be affected inside the function?
Like I have this function, it’s big and large.
If I can have this function in the utility.lua
and just change the objects, I think it will be wonderful.
local function ballTouch( event ) if "began" == event.phase then audio.play (peau) ball.isFocus = true txPe.isVisible = true local function resetPelota () txPe.isVisible = false txPe.y = 730 end transition.to(txPe, {time=2000, y=680, onComplete=resetPelota}) txBall.isVisible = true local function resetBall () txBall.isVisible = false txBall.y = txPe.y + 40 end transition.to(txBall, {time=2000, y=(680 + 40), onComplete=resetBall}) ball.x0 = event.x - ball.x ball.y0 = event.y - ball.y elseif ball.isFocus then if "moved" == event.phase then ball.x = event.x - ball.x0 ball.y = event.y - ball.y0 if ball.x == 226 then transition.to(ball, {time=100, x=226, y=665}) ball:removeEventListener ("touch", ballTouch) audio.play(win) coinPelota.isVisible = true transition.to(coinPelota, {time=1000, x=glowCoin.x, y=40, onComplete=utility.glow(glowCoin)}) addToScore(10) end elseif "ended" == phase or "cancelled" == phase then ball.isFocus = false end end -- Return true if the touch event has been handled. return true end
As you can see, I have
– a ball object
– a txPe
– txBall
– coinPelota
and also functions inside functions…
And for my game I need like 12 functions like this, and that is just in one page
and I need like 10 pages…
So I have to write the same function
local function ballTouch( event ) end
like 150 times
all I have to change it’s that instead of “ball” now it will be “bed” or “toy”
is there a way to make this work?