I am using removeSelf() of a number of display objects, and it works properly, but gives me this error shown at the bottom of the code.
local dug = display.newImage("images/dugOut.png", 0, 0)
--physics.addBody( dug, "static", { friction=0.6 } )
dug.alpha = 0.5254901960784314
dug.collisionType = "dug"
dug.timesHit = 0
dug.points = 0
hbLeft = display.newImage("images/hitBorder.png", 120, 0)
physics.addBody( hbLeft, "static", { friction=0.6 } )
hbLeft.collisionType = "dug"
hb1 = display.newImage("images/hitBorder.png", 28, 0)
physics.addBody( hb1, "static", { friction=0.6 } )
hb1.collisionType = "dug"
hb2 = display.newImage("images/hitBorder.png", 120, 0)
physics.addBody( hb2, "static", { friction=0.6 } )
hb2.collisionType = "dug"
hb3 = display.newImage("images/hitBorder.png", 360, 0)
physics.addBody( hb3, "static", { friction=0.6 } )
hb3.collisionType = "dug"
hb4 = display.newImage("images/hitBorder.png", 450, 0)
physics.addBody( hb4, "static", { friction=0.6 } )
hb4.collisionType = "dug"
local function removeSetup()
dug:removeSelf()
hb1:removeSelf()
hb2:removeSelf()
hb3:removeSelf()
hb4:removeSelf()
buttonSmall:removeSelf()
end
buttonHandler = function( event )
--t:setText( "id = " .. event.id .. ", phase = " .. event.phase )
timer.performWithDelay(1000, removeSetup)
--dug:removeSelf()
--hb1:removeSelf()
--hb2:removeSelf()
--hb3:removeSelf()
--hb4:removeSelf()
--t = event.target
--t:removeSelf()
end
buttonSmall = ui.newButton{
default = "images/buttonBlueSmall.png",
over = "images/buttonBlueSmallOver.png",
onEvent = buttonHandler,
id = "smallBtn",
text = "Fight",
size = 12,
emboss=true
}
buttonSmall.x = 240; buttonSmall.y = 160
Output Error
Copyright (C) 2009-2010 A n s c a , I n c .
Version: 2.0.0
Build: 2010.243
The file sandbox for this project is located at the following folder:
(/Users/derwydd/Library/Application Support/Corona Simulator/game3-2188ABD515A7F5EC2C73D852830661CB)
Runtime error
...kiiClover/Capture the Flag/game3/sticksAndStones.lua:35: attempt to call method 'removeSelf' (a nil value)
stack traceback:
[C]: in function 'removeSelf'
...kiiClover/Capture the Flag/game3/sticksAndStones.lua:35: in function '\_listener'
?: in function <?:441>
?: in function <?:214>
[import]uid: 7197 topic_id: 4894 reply_id: 304894[/import]