Really simple loader example

3 replies [Last post]
freshworks
User offline. Last seen 6 weeks 6 days ago. Offline
Joined: 25 Aug 2009

Ok, i'am just one day working within Corona, but tried something, please adapt the code or make it better to help others and also me :)

If you could use it, be happy.

Cheers Freshworks

-------------------------------------------
-- Improvised loader example
-------------------------------------------
-- JUST SIMPLE LOADER EXAMPLE
txtloading = display.newText("LOADING",140,200)
txtloading:setTextColor(255,255,255)

local loader = display.newGroup()

-- UPDATE LOADER
local function updateLoader(perc)
local bar = display.newRect(120,240,perc,10)
bar:setFillColor(255,255,255)
loader:insert(bar)
end

-- LOAD CONTENT AND UPDATE THE LOADERBAR BY HAND

-- load file / content or whatever :)
updateLoader(10)
-- load file / content or whatever :)
updateLoader(20)
-- load file / content or whatever :)
updateLoader(30)
-- load file / content or whatever :)
updateLoader(40)
-- load file / content or whatever :)
updateLoader(50)
-- load file / content or whatever :)
updateLoader(60)
-- load file / content or whatever :)
updateLoader(70)
-- load file / content or whatever :)
updateLoader(80)
-- load file / content or whatever :)
updateLoader(90)
-- load file / content or whatever :)
updateLoader(100)

-- Release the loaderbars
for i=loader.numChildren,1,-1 do
local child = loader[i]
child.parent:remove( child )
end

txtloading:setTextColor(0,0,0) -- DO NOT NOW HOW TO RELEASE YET :)
--txtloading:remove <== won't work

-- MAINROUTINE
function main ( event )
-- worlds bestgamecode :)
txtloaded = display.newText("LOADING DONE..",115,200)
txtloaded:setTextColor(255,255,255)
end

-- START THE MAIN ROUTINE
Runtime:addEventListener("enterFrame",main)

Replies

willsingleton
User offline. Last seen 13 weeks 6 days ago. Offline
Joined: 3 Sep 2009

Thanks - I'll try it out!

happylewie's picture
happylewie
User offline. Last seen 3 days 11 min ago. Offline
Joined: 26 Jun 2009

Quote:

1
2
txtloading:setTextColor(0,0,0) -- DO NOT NOW HOW TO RELEASE YET :)
--txtloading:remove <== won't work

Have you tried txtloading = nil? That would empty any value for txtloading.

freshworks
User offline. Last seen 6 weeks 6 days ago. Offline
Joined: 25 Aug 2009

Thanks happylewie, that will do the job.

Cheers

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.