我有这段代码,使用display.newCircle在屏幕上绘制一条线。它完美的作品,但当我画更多它会更不稳定和泄漏内存 。 我如何保持优化。 问题只出现在设备上。 这里是代码Corona SDK绘制线条使用圆圈
local background = display.newRect(0, 0, 480, 800)
local lines = {};
local i = 1;
local strokeWidth = 20;
local R = 150;
local G = 100;
local B = 50;
local function drawALine(event)
if event.phase == "began" then
elseif event.phase == "moved" then
lines[i] = display.newCircle(event.x, event.y, strokeWidth, strokeWidth);
lines[i]:setFillColor(R,G,B);
elseif event.phase == "ended" then
end
end
Runtime:addEventListener("touch", drawALine)
任何帮助吗?
你的意思是不稳定的? – Schollii
这是你的main.lua吗?你不使用场景或createScene事件? – Schollii
不,它不是main.lua我使用导演类来改变场景,我已经添加在这样的组中'lines [i] = display.newCircle(paintGroup,event.x,event.y,strokeWidth,strokeWidth); '但这不会改变任何东西 – Beri