Small Graphic Demo W/2 Scenes-Code OK?-Download Included!

Hi,

I used Corona SDK and Lua for about 2 days and below is what I managed to make:

Click HERE to download a compressed ZIP file of entire demo project.

Code is below also:

(Please let me know in this thread about issues with code, thanks!)

-- "main.lua" -- -- ------------------------------------------------------------------------------------------------------------- -- JeZxLee's -- \_ \_ \_ \_ \_\_ \_\_\_\_ \_\_\_\_ \_\_ \_\_ \_\_\_\_ \_\_ \_\_ \_ \_\_\_ \_\_\_\_ \_\_ \_\_\_\_TM\_ \_ -- (/(/( \/ ) / \( \_ \(\_ \_)/ \_\ ( ) ( \_ \ / \ ( ( \ / \_\_) ( \_ \ / \_\(\_ \_)(/(/ -- / \/ \( O )) / )( / \/ (\_/\ ) \_\_/( O )/ /( (\_ \ ) \_ (/ \ )( -- \_)(\_/ \_\_/(\_\_\_) (\_\_)\_/\_/\_\_\_\_/ (\_\_) \_\_/ \_)\_\_) \_\_\_/ (\_\_\_\_/\_/\_/(\_\_) -- -- One Game + One Handheld Device + Two Player Simultaneous -- -- (C)opyright 2017 By Team 16BitSoft -- www.16BitSoft.com -- -- ------------------------------------------------------------------------------------------------------------- TextObjectsIndex = -1 TotalNumberOfCachedTexts = 100 TextObjects = {} for i = 0, TotalNumberOfCachedTexts do TextObjects[i] = nil end SceneTimer = -1 local composer = require( "composer" ) composer.gotoScene( "scene16BitSoft" ) -- "A 110% By Team 16BitSoft"

-- "mathFunct.lua" local MathFunct={}; function MathFunct.round(x, n) n = math.pow(10, n or 0) x = x \* n if x \>= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end return x / n end -- ------------------------------------------------------------------------------------------------------------- return MathFunct

-- "visualsFunct.lua" local VisualsFunct={}; function VisualsFunct.drawTextOntoScene( text, font, size, fillR, fillG, fillB, lineR, lineG, lineB, textX, textY ) if TextObjectsIndex \< (TotalNumberOfCachedTexts-1) then TextObjectsIndex = TextObjectsIndex + 1 else TextObjectsIndex = 0 end local i = TextObjectsIndex TextObjects[i] = display.newEmbossedText( text, textX, textY, font, size ) TextObjects[i]:setFillColor( fillR, fillG, fillB ) local colorOutline = { highlight = { r = lineR, g = lineG, b = lineB }, shadow = { r = lineR, g = lineG, b = lineB } } TextObjects[i]:setEmbossColor( colorOutline ) return TextObjects[i] end -- ------------------------------------------------------------------------------------------------------------- function VisualsFunct.destroyAllTextOnScene() for i = 0, TotalNumberOfCachedTexts do if TextObjects[i] ~= nil then TextObjects[i]:removeSelf() end TextObjects[i] = nil end TextObjectsIndex = -1; end -- ------------------------------------------------------------------------------------------------------------- return VisualsFunct

-- "scene16BitSoft.lua" local composer = require( "composer" ) local scene = composer.newScene() local mathFunct = require( "mathFunct" ) local visualsFunct = require( "visualsFunct" ) -- ------------------------------------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view local myRectangle = display.newRect( display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight ) myRectangle.strokeWidth = 3 myRectangle:setFillColor( 0 ) myRectangle:setStrokeColor( 0, 0, 0 ) sceneGroup:insert( myRectangle ) local gameDevCompTwo = display.newImage( "/data/visuals/16BitSoftLogo.png" ) gameDevCompTwo:translate( display.contentCenterX, display.contentCenterY ) gameDevCompTwo.xScale = -1; gameDevCompTwo.yScale = -1; sceneGroup:insert( gameDevCompTwo ) gameDevCompTwo:translate( 0, ( (gameDevCompTwo.contentHeight/2) \* -1) ) sceneGroup:insert( visualsFunct.drawTextOntoScene( "www.16BitSoft.com", "Font01.ttf", 30, 0, 1, 0, 0.5, 0, 0, display.contentCenterX, 0 ) ) TextObjects[0].xScale = -1; TextObjects[0].yScale = -1; TextObjects[0]:translate( 0, ( (TextObjects[0].contentHeight/2) \* 1) ) local gameDevComp = display.newImage( "/data/visuals/16BitSoftLogo.png" ) gameDevComp:translate( display.contentCenterX, display.contentCenterY ) sceneGroup:insert( gameDevComp ) gameDevComp:translate( 0, ( (gameDevComp.contentHeight/2) \* 1) ) sceneGroup:insert( visualsFunct.drawTextOntoScene( "www.16BitSoft.com", "Font01.ttf", 30, 0, 1, 0, 0.5, 0, 0, display.contentCenterX, display.contentHeight ) ) TextObjects[1]:translate( 0, ( (TextObjects[1].contentHeight/2) \* -1) ) end -- ------------------------------------------------------------------------------------------------------------- function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then local function tapListener( event ) SceneTimer = 0 return true end local function onEveryFrame( event ) if SceneTimer \> 0 then SceneTimer = SceneTimer - 1 else SceneTimer = 0; Runtime:removeEventListener( "tap", tapListener ) Runtime:removeEventListener( "enterFrame", onEveryFrame ) local options = { effect = "fade", time = 500--, } composer.gotoScene( "sceneTitle", options ) end end Runtime:addEventListener( "enterFrame", onEveryFrame ) Runtime:addEventListener( "tap", tapListener ) SceneTimer = 250 end end -- ------------------------------------------------------------------------------------------------------------- function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- ------------------------------------------------------------------------------------------------------------- function scene:destroy( event ) local sceneGroup = self.view myRectangle:removeSelf() myRectangle = nil gameDevCompTwo:removeSelf() gameDevCompTwo = nil gameDevComp:removeSelf() gameDevComp = nil visualsFunct.destroyAllTextOnScene( ) sceneGroup:removeEventListener( "create", scene ) sceneGroup:removeEventListener( "show", scene ) sceneGroup:removeEventListener( "hide", scene ) sceneGroup:removeEventListener( "destroy", scene ) end -- ------------------------------------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ------------------------------------------------------------------------------------------------------------- return scene

-- "sceneTitle.lua" local composer = require( "composer" ) local scene = composer.newScene() local mathFunct = require( "mathFunct" ) local visualsFunct = require( "visualsFunct" ) -- ------------------------------------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view SceneTimer = 250 local myRectangle = display.newRect( display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight ) myRectangle.strokeWidth = 3 myRectangle:setFillColor( 0.5 ) myRectangle:setStrokeColor( 0, 0, 0 ) sceneGroup:insert( myRectangle ) end -- ------------------------------------------------------------------------------------------------------------- function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then local function tapListener( event ) SceneTimer = 0 return true end local function onEveryFrame( event ) if SceneTimer \> 0 then SceneTimer = SceneTimer - 1 else SceneTimer = 0; Runtime:removeEventListener( "tap", tapListener ) Runtime:removeEventListener( "enterFrame", onEveryFrame ) local options = { effect = "fade", time = 500--, } composer.gotoScene( "scene16BitSoft", options ) end end Runtime:addEventListener( "enterFrame", onEveryFrame ) Runtime:addEventListener( "tap", tapListener ) SceneTimer = 250 end end -- ------------------------------------------------------------------------------------------------------------- function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- ------------------------------------------------------------------------------------------------------------- function scene:destroy( event ) local sceneGroup = self.view myRectangle:removeSelf() myRectangle = nil visualsFunct.destroyAllTextOnScene( ) sceneGroup:removeEventListener( "create", scene ) sceneGroup:removeEventListener( "show", scene ) sceneGroup:removeEventListener( "hide", scene ) sceneGroup:removeEventListener( "destroy", scene ) end -- ------------------------------------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ------------------------------------------------------------------------------------------------------------- return scene

JeZxLee

Hi,

So the above demo project runs perfect in the Corona Simulator.

The above demo project also runs perfect when exported to EXE for Windows (on Win 10 Pro 64).

The above demo DOES NOT work when exported to APK for Android on real Samsung S7 Edge smartphone?

APK installs & demo does show the “Powered By Corona Labs” screen, but then shows empty black screeen?

Any help would be appreciated, thanks!

JeZxLee

This question is being addressed in this thread:

https://forums.coronalabs.com/topic/67766-100-simulator-windows-android-black-screen-crash-after-corona-labs-screen/

Please contribute there.

Rob

Hi,

So the above demo project runs perfect in the Corona Simulator.

The above demo project also runs perfect when exported to EXE for Windows (on Win 10 Pro 64).

The above demo DOES NOT work when exported to APK for Android on real Samsung S7 Edge smartphone?

APK installs & demo does show the “Powered By Corona Labs” screen, but then shows empty black screeen?

Any help would be appreciated, thanks!

JeZxLee

This question is being addressed in this thread:

https://forums.coronalabs.com/topic/67766-100-simulator-windows-android-black-screen-crash-after-corona-labs-screen/

Please contribute there.

Rob