-- This is the source scene
json = require('json')
LoadingScene = Core.class(Sprite)
local json_loaded = false
function LoadingScene:init()
print("inside loading scene")
local bg = Bitmap.new(Texture.new("images/bg.png"))
bg:setAnchorPoint(0.5, 0.5);
bg:setPosition(conf.width/2, conf.height/2)
self:addChild(bg)
-- Setup loading spinner
local texture = Texture.new("images/spinner.png")
local bitmaps = {}
local len = 10
for i=1, 19 do
bitmaps[#bitmaps+1] = {(i-1)*len+1, i*len, Bitmap.new(TextureRegion.new(texture, 0, (i-1)*108, 108, 108))}
end
local mc = MovieClip.new(bitmaps)
mc:setGotoAction(19*len, 1)
mc:gotoAndPlay(1)
mc:setPosition(conf.width/2 - 54, conf.height/2 - 54) -- TODO: Offset by image width
self:addChild(mc)
local aboutText = TextWrap.new("Loading", 100, "justify", 5, conf.fontMedium)
aboutText:setTextColor(0xffff00)
aboutText:setPosition(conf.width/2 - 50, conf.height/2 + 100)
self:addChild(aboutText)
-- END : Setup loading spinner
local f = io.open("|R|data_files/" .. conf.current_cardset.path, "r")
local data = f:read("*all")
conf.data = json.decode(data)
f:close()
json_loaded = true
-- run world
self:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
self:addEventListener("enterEnd", self.onEnterEnd, self)
end
function LoadingScene:onEnterEnd()
if json_loaded then
print("json was loaded")
--mc.stop()
sceneManager:changeScene("cards", conf.transitionTime, conf.transition, conf.easing)
end
end
function LoadingScene:onEnterFrame()
end
Comments
Also by making json_loaded outside the class, once you set it to true, it never goes back to false.
Thanks. I moved it to the
Likes: antix
Yep; it's only executing once.
I added