Hi everyone.
Maybe this is not so newbie question, but I put it here anyway.
I have a game that needs 12 functions –
or I should say, 1 function repeat it 12 times.
it just changes a little bit here and there.
I got the error that I have more than 60 upvalues. so I can not keep writting more code.
I guess I need to make just one function and use it for all the 12 objects.
I do need some help. thanks.
this is the function
cloud = display.newImage("cloud4.png") group:insert(cloud) cloud.x = 900; cloud.y = 180 cloud:scale (1.6, 1.6) cloud.name = "cloud" local function cloudListener (event) addToScore(10) audio.play(win) cloud:removeEventListener("tap", cloudListener) blancoEspanol.isVisible = true -- las nubes son blancas blancoEnglish.isVisible = true -- the clouds are white coinCloud.isVisible = true transition.to(coinCloud, {time=1000, x=glowCoin.x, y=glowCoin.y}) transition.to(blancoEspanol, {time=100, delay=3000, x=-300}) local function showPink () txBlanco.isVisible = false txWhite.isVisible = false txRosa.isVisible = true txPink.isVisible = true airplane.isVisible = true transition.to(airplane, {time=1000, x=300, y=120}) imageScoreLabel:toFront() imageScoreObject:toFront() scoreObject:toFront() end transition.to(blancoEnglish, {time=100, delay=3000, x=1300, onComplete=showPink}) return true end cloud:addEventListener("tap", cloudListener) cloud.isVisible = false
I have an idea but I need a little extra.
I guess I have to put a – local object = event.target
so instead of – airplane.isVisible
I write – object.isVisible
I have an idea but I don’t really know what to do. Please help me out
