hi,
I would like to change a background image depending on the score(“number”)
but my problem is that my background superimposes them because the functions are repeated with the runtime.
What is the best way to do what i would like ?
thanks for your response
local numberglass = 1 local flagGlass = 0 local imageGlass = {} imageGlass[1]="eclat.png" imageGlass[2]="eclat2.png" imageGlass[3]="eclat3.png" imageg=imageGlass[numberglass] local function glassLevel1() if flagGlass == 0 then flagGlass = 1 local glass = display.newImage(imageGlass[numberglass]) glass.x = 240 glass.y = 160 glass.xScale = 0.5 glass.yScale = 0.5 end return glass, flagGlass, flagGlassRemove end local function glassLevel2() if flagGlass == 1 then flagGlass = 0 display.remove(glass) glass = nil local glass = display.newImage(imageGlass[numberglass + 1]) glass.x = 240 glass.y = 160 glass.xScale = 0.5 glass.yScale = 0.5 end return glass, flagGlass end local function glassLevel3() if flagGlass == 0 then flagGlass = 1 display.remove(glass) glass = nil local glass = display.newImage(imageGlass[numberglass + 1]) glass.x = 240 glass.y = 160 glass.xScale = 0.5 glass.yScale = 0.5 end return glass, flagGlass end local function testNumber (event) print("number", number) if number \< 10 then glassLevel1() end if number \>= 10 and number \< 20 then glassLevel2() end if number \>= 20 then glassLevel3() end end Runtime:addEventListener("enterFrame", testNumber)