Skip to content

Commit

Permalink
avoid memory leak for lua and invoke unscheduleScriptFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
minggo committed Sep 28, 2011
1 parent bd273c7 commit 2180e53
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion HelloLua/Resource/hello.lua
Expand Up @@ -35,6 +35,7 @@ function btnTouchMove(e)
end

function btnTouchBegin(e)
cocos2d.CCScheduler:sharedScheduler():unscheduleScriptFunc("tick")
cocos2d.CCLuaLog("btnTouchBegin")
for k,v in ipairs(e) do
pointBegin = v:locationInView(v:view())
Expand Down Expand Up @@ -136,7 +137,7 @@ layerMenu:addChild(menuTools)

function tick()

point = spriteDog:getPosition();
local point = spriteDog:getPosition();

if point.x > winSize.width then
point.x = 0
Expand All @@ -148,6 +149,11 @@ function tick()

end

-- avoid memory leak
collectgarbage( "setpause", 100)
collectgarbage( "setstepmul", 5000)


cocos2d.CCScheduler:sharedScheduler():scheduleScriptFunc("tick", 0.01, false)

-- play background music
Expand Down

0 comments on commit 2180e53

Please sign in to comment.