1
我创造了我的游戏中的云,我想在20秒后删除。问题是,当我添加代码来删除它们时,云甚至不会出现,看起来它们在创建时就被删除了。Corona SDK:延迟后删除对象
这里有两种方法我试过已经(其中没有工作):
local function removeBody(body)
body:removeSelf()
end
local function newCloud()
local n = cloudNumber
while n==cloudNumber do
n = math.random(1,5)
end
cloudNumber=n
local cloud = display.newImage(imageNames[cloudNumber], screenW+30, screenH*0.2)
timer.performWithDelay(6000, newCloud)
cloud.myName="cloud"
physics.addBody (cloud, {isSensor=true})
cloud:setLinearVelocity(-25,0)
cloud.gravityScale=0
timer.performWithDelay(20000,removeBody(cloud))
end
和
local function newCloud()
local n = cloudNumber
while n==cloudNumber do
n = math.random(1,5)
end
cloudNumber=n
local cloud = display.newImage(imageNames[cloudNumber], screenW+30, screenH*0.2)
timer.performWithDelay(6000, newCloud)
cloud.myName="cloud"
physics.addBody (cloud, {isSensor=true})
cloud:setLinearVelocity(-25,0)
cloud.gravityScale=0
--timer.performWithDelay(20000, cloud:removeSelf())
end
我该怎么办? 谢谢!
完美!谢谢! – dietbacon