Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Implement LOADING scene. — Gideros Forum

Implement LOADING scene.

edited August 2013 in General questions
Hi guys,

My game need to load a bundle of background graphics, so there is a delay (freeze) when I press START GAME button.

I implemented a loading bar while calling loadBackground() before call enterFrame() event.

However it didn't work. When I move to a new scene, game still freeze (like it need to load all resource before calling scene:init()), the loading bar appear later.

Any tips to implement this? Thank you :)

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited September 2013 Accepted Answer
    Here is a modified version of scene manager that I use to display loading image between scenes:
    function SceneManager:changeScene(scene, duration, transition, ease)
    	if self.tweening then
    		return
    	end
    	if self.hasNext then
    		return
    	end
    	loader:show()
    	self.hasNext = true
    	Timer.delayedCall(1, function()
    		if self.scene1 == nil then
    			self.scene1 = self.scenes[scene].new()
    			self:addChild(self.scene1)
    			loader:hide()
    			self.hasNext = false
    			dispatchEvent(self, "transitionBegin")
    			dispatchEvent(self.scene1, "enterBegin")
    			dispatchEvent(self, "transitionEnd")
    			dispatchEvent(self.scene1, "enterEnd")
    			return
    		end
     
    		self.duration = duration
    		self.transition = transition
    		self.ease = ease or defaultEase
     
    		self.scene2 = self.scenes[scene].new()
    		self.scene2:setVisible(false)
    		self:addChild(self.scene2)
    		loader:hide()
     
    		self.time = 0
    		self.currentTimer = os.timer()
    		self.tweening = true
    		self.hasNext = false
    	end)
    end
    loader:show() function is what adds loading image to the stage
    loader:hide() then removes it
    so replace them with your own calls
    Timer.delayedCall(1, function()end) is meant to skip one enter frame so it loads the image before starts loading assets of the scene.

    ;)
    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.