Thanks!
But there is a little problem. When i’m running my test-app using the code below it let me change from Locked to Unlocked(when im clicking the BTN). But when i click on BG it wont change to Clear. I have try to fix this code for a long time now and i cant manage the last part. When i touch BG, Locked will be removed and Clear should be displayed instead, but that doesnt happen. I’m getting an error in line 42 but I really cant se the problem:/
Here’s my code:
[lua]local BG = display.newImage (“background.png”)
BG.x = display.contentWidth /2
BG.y = display.contentHeight /2
local BTN = display.newImage (“Unlock.png”)
BTN.x = display.contentWidth /2
BTN.y = 300
_G.button = 1
if _G.button == 1 then
Locked = display.newImage(“Level_Locked.png”)
Locked.x = display.contentWidth /2
Locked.y = display.contentHeight /3
end
local function changeImage ()
if _G.button == 2 then
local UnLocked = display.newImage(“Level_Playable.png”)
UnLocked.x = display.contentWidth /2
UnLocked.y = display.contentHeight /3
end
end
local function UnLock (event)
if event.phase == “ended” then
_G.button = 2
Locked:removeSelf()
changeImage()
BTN:removeEventListener(“touch”,UnLock)
end
end
local function changeIt ()
if _G.button == 3 then
local Clear = display.newImage(“Level_Clear.png”)
Clear.x = display.contentWidth /2
Clear.y = display.contentHeight /3
end
end
local function Comp (event)
if event.phase == “ended” then
_G.button = 3
UnLocked:removeSelf()
changeIt()
BG:removeEventListener(“touch”,Comp)
end
end
BTN:addEventListener(“touch”,UnLock)
BG:addEventListener(“touch”,Comp) [import]uid: 119384 topic_id: 22637 reply_id: 90944[/import]