【发布时间】:2013-10-18 19:47:36
【问题描述】:
我有一个按钮,每次触摸按钮时都会创建并施加力。 如何防止这种情况泄漏内存?
我正在使用导演课程从一个场景切换到另一个场景。 代码如下:
-- Fire the rocket from the jet position
local function fireTheRocket(event)
if event.phase == "ended" then
local fireBall = display.newImage( "rocket.png")
fireBall.x = jet.x;
fireBall.y = jet.y;
GUI:insert(fireBall);
physics.addBody(fireBall, "dynamic")
fireBall:applyForce( 1000, 0, fireBall.x, fireBall.y )
end
end
fireBtn:addEventListener("touch", fireTheRocket)
【问题讨论】:
-
我的意见是将此图像添加到一个数组中。设置计时器以删除数组中的子图像。