I was shocked when I compiled our apps for android tablets, the loading times of bitmaps are really bad (compared to iOS).
As you can see in the table this is due to the slow memory data transfer in the Galaxy Tablet 1000, Amazon Kindle Fire and the Nook Tablet.
I’m using LevelHelper as a 3rd party tool, for this I pay small penalty of .25 to .5 sec depending on the device, but this is acceptable.
http://apps.oetingerverlag.de/LoadingTimes.png
The two sprite sheets loaded with the level helper level or loaded directly into memory for this test are 1024x992 pixel (1.3 MB) and 2048x2048 pixel (2.9 MB) big.
For the preloading test I just loaded the images into memory before I loaded the images again, directly or using level helper.
I just wanted to test if Corona really checks if a bitmap is already loaded and doesn’t reload it again. As you can see, Corona works correctly.
If you’re interested, here’s the simple code (daily build 783, LH code revision r9) for the test, use your own sprite sheets and level helper level (or adapt it for Lime, this would be interesting):
[lua]display.setStatusBar( display.HiddenStatusBar )
require “LevelHelperLoader”
local lh
– variables
local myLhSpriteBear
local myTextButton1
local myTextButton2
local myTextButton3
local loadingTime
local preloadSceneBG
local preloadSceneItems
local loadSceneBG
local loadSceneItems
– main function
local function showLoadingTime( elapsedTime )
local mYInfoBG = display.newRoundedRect( 112, 430, 800, 100, 10 )
mYInfoBG:setFillColor( 255, 0, 0 )
local myInfoText = display.newText( “LOADING TIME: “…(math.round(elapsedTime)/1000)…” sec”, 160, 450, “Helvetica”, 48 )
myInfoText:setTextColor(255, 255, 255)
end
local function preloadImages( event )
if event.phase == “began” then
print(“PRELOADED IMAGES FOR LEVEL”)
myTextButton1:removeEventListener( “touch”, preloadImages )
myTextButton1:setTextColor(150, 150, 150)
– LOAD ONLY THE IMAGES FOR LH LEVEL HERE
preloadSceneBG = display.newImage( “Images/scene02BGElements.png”, true )
preloadSceneBG.isVisible = false
preloadSceneItems = display.newImage( “Images/scene02BGElementsPapaLarsWalk.png”, true )
preloadSceneItems.isVisible = false
end
end
local function loadImages( event )
if event.phase == “began” then
print(“LOADED IMAGES WITHOUT LEVELHELPER”)
myTextButton2:removeEventListener( “touch”, loadImages )
loadingTime = system.getTimer()
– LOAD ONLY THE IMAGES FOR LH LEVEL HERE
loadSceneBG = display.newImage( “Images/scene02BGElements.png”, true )
loadSceneItems = display.newImage( “Images/scene02BGElementsPapaLarsWalk.png”, true )
showLoadingTime( system.getTimer() - loadingTime)
end
end
local function loadLHLevel( event )
if event.phase == “began” then
print(“LOADED IMAGES USING LEVELHELPER”)
myTextButton3:removeEventListener( “touch”, loadLHLevel )
loadingTime = system.getTimer()
– LOAD YOUR OWN LH LEVEL HERE
lh = LevelHelperLoader:initWithContentOfFile(“scene02.plhs”)
lh:instantiateSprites()
showLoadingTime( system.getTimer() - loadingTime)
end
end
– Main function
local function main()
local mYButtonBG1 = display.newRoundedRect( 112, 130, 800, 100, 10 )
mYButtonBG1:setFillColor( 255, 0, 0 )
myTextButton1 = display.newText( “PRELOAD IMAGES”, 270, 150, “Helvetica”, 48 )
myTextButton1:setTextColor(255, 255, 255)
myTextButton1:addEventListener( “touch”, preloadImages )
local mYButtonBG2 = display.newRoundedRect( 112, 280, 800, 100, 10 )
mYButtonBG2:setFillColor( 100, 100, 100 )
myTextButton2 = display.newText( “LOAD ONLY IMAGES”, 270, 300, “Helvetica”, 48 )
myTextButton2:setTextColor(255, 255, 255)
myTextButton2:addEventListener( “touch”, loadImages )
local mYButtonBG3 = display.newRoundedRect( 112, 430, 800, 100, 10 )
mYButtonBG3:setFillColor( 100, 100, 100 )
myTextButton3 = display.newText( “LOAD IMAGES WITH LH LEVEL”, 160, 450, “Helvetica”, 48 )
myTextButton3:setTextColor(255, 255, 255)
myTextButton3:addEventListener( “touch”, loadLHLevel )
return true
end
– Start Main
main()[/lua] [import]uid: 107675 topic_id: 25457 reply_id: 325457[/import]