Last active
August 15, 2017 16:37
-
-
Save Shchvova/3d7fecc371f728e66264690a416d2acc to your computer and use it in GitHub Desktop.
Corona Batching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- For more information on build.settings, see the Project Build Settings guide at: | |
-- https://docs.coronalabs.com/guide/distribution/buildSettings | |
-- | |
settings = | |
{ | |
orientation = | |
{ | |
-- Supported values for orientation: | |
-- portrait, portraitUpsideDown, landscapeLeft, landscapeRight | |
default = "portrait", | |
supported = { "portrait", }, | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- For more information on config.lua see the Project Configuration Guide at: | |
-- https://docs.coronalabs.com/guide/basics/configSettings | |
-- | |
application = | |
{ | |
content = | |
{ | |
width = 240, | |
height = 320, | |
scale = "letterbox", | |
fps = 60, | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local group, trans, mode = display.newGroup(), nil, "individual" | |
local fpsText = display.newText(display.fps, display.contentCenterX, display.contentHeight - 30, native.systemFont, 16) | |
local function toggleMode( ) | |
group:removeSelf() | |
group = display.newGroup() | |
local numberOfImages = 10000 | |
if mode == "individual" then | |
for i=1,numberOfImages do | |
display.newImageRect(group, "gem.png", 30, 30 ):translate( math.random(display.contentWidth), math.random( display.contentHeight ) ) | |
end | |
mode = "batched" | |
else | |
for i=1,numberOfImages/2 do | |
display.newImageRect(group, "gem.png", 30, 30 ):translate( math.random(display.contentWidth), math.random( display.contentHeight ) ) | |
display.newImageRect(group, "gem2.png", 30, 30 ):translate( math.random(display.contentWidth), math.random( display.contentHeight ) ) | |
end | |
mode = "individual" | |
end | |
transition.cancel( trans ) | |
trans = transition.blink( group, {time = 5000} ) | |
fpsText:toFront( ) | |
end | |
toggleMode() | |
local startTime, accNum, maxCount = 0, 0, 100 | |
Runtime:addEventListener("enterFrame", function( e ) | |
accNum = accNum + 1 | |
if accNum >= maxCount then | |
fpsText.text = mode .. " fps: " .. math.round( 1000*maxCount/(e.time - startTime) ) | |
accNum, startTime = 0, e.time | |
end | |
end) | |
fpsText:addEventListener("tap", toggleMode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment