Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Using frameCount to manage your game. — Gideros Forum

Using frameCount to manage your game.

edited January 2013 in User experience
Hi @twisttap ,

Try this code:

function game:init()
        --initial preparation, draw background, panel, etc...
        startGame()
end
 
local function moveObject()		
        for i = grpBomb:getNumChildren(), 1, -1 do
	      local bomb = grpBomb:getChildAt(i)
	      bomb:getX() = bomb:getX() + 1 
              --it's up to you
        end
end
 
local function runGame(event)
	if gameIsActive then
		frameCount = frameCount + 1
		moveObject()
	end
end
 
function startListeners()
	stage:addEventListener(Event.ENTER_FRAME, runGame)
end
 
function stopListeners()
	stage:removeEventListener(Event.ENTER_FRAME, runGame)
end
 
function startGame()
        stage:addChild(grpGame) 
	grpGame:addChild(grpBackground)  
        grpGame:addChild(grpBomb)  
        --add any sprite group you want
        startListeners()
end



If you have any question, don't hesitate to ask :D
Sign In or Register to comment.