I’m using a different image atm that I already have running so I replaced robber with ghost and also have a cloud image scrolling above.
So its still not working and there is no error, everything works and shows up but the ghost is not clickable and will not remove it self when clicked/touch. Ive read many many tutorials but cant seem to find one that works so something is obviously not right, here is my main.lua file.
display.setStatusBar(display.HiddenStatusBar)
– Setup Graphics
local background = display.newImage(“background.jpg”)
local ghost = display.newImage(“ghost.png”)
ghost.x = 300
ghost.y = 590
local cloudwhite = display.newImage(“cloudwhite.png”)
cloudwhite:setReferencePoint(display.BottomLeftReferencePoint)
cloudwhite.x = 940
function scrollcloudwhite(self,event)
if self.x < -220 then
self.x = 940
else
self.x = self.x - 1
end
end
cloudwhite.enterFrame = scrollcloudwhite
Runtime:addEventListener(“enterFrame”, cloudwhite)
local function touchGhost( event )
if ( event.phase == “ended” ) then
event.target:removeSelf() ; event.target = nil
end
return true
end
local function spawnGhost()
local Ghost = display.newImageRect(“Ghost.png”, 45, 45);
ghost.x = mRand(50, _W-50); ghost.y = mRand(50, _H-50);
ghost:addEventListener( “touch”, touchGhost )
end