Hi Experts,
I have built a project for android using storyboard. Everything works as expected on the simulator but on actual devices ( tried many) I am facing many issues, possibly because of storyboard.
-
Below is the pseudo code of what I am doing. The objects initiated in createScene are not getting displayed on device properly ( some of the objects are displayed, some of them are not…some of the sprite animation is working, some are not…some of the (transition.to)'s are working, some are not…etc…looks like only first couple of objects are getting initiated )
-
event listeners are not getting added to the objects on device but works good on sim.
PS–> Please note that i have tried multiple android devices ( and also bluestock) but the issues are same everywhere except on corona simulator where the game works awesome !
Am i missing anything here ? What i am doing wrong ? any suggestions/tips/help appreciated ! is there any thing I need to do at config file ?
[lua]local physics = require( “physics” )
local json = require(“json”)
local storyboard = require (“storyboard”)
local widget = require (“widget”)
local playfile = require (“play”)
local ani = require “sprite”
local scene = storyboard.newScene()
physics.start()
physics.setGravity( 0,1 )
— Declaring shapes from Gumbo --------------------------------------------------------------------
local shape_1 = { -237,-94, -228,-110, -178,-134, -124,-138, -99,-129, -99,-129, -122,-99, -151,-96 }
shape_1.density = 1; shape_1.friction = 0.3; shape_1.bounce = 0.2;
– above is just an example, I am defining multiple other shapes here–
– Declaring objects ---------------------------------------------------------------------------------
local object1 = display.newImageRect( “object.png”,10,10 )
local object2 = display.newImageRect( “object.png”,10,10 )
local object3 = display.newImageRect( “object.png”,10,10 )
local powerup1 = display.newImageRect( “powerup.png”,10,10 )
local powerup2 = display.newImageRect( “powerup.png”,10,10 )
local powerup3 = display.newImageRect( “powerup.png”,10,10 )
----just example, I am declaring around 30-40 objects here—
function scene:createScene(event)
local screenGroup = self.view
–Initializing sprites, assigning properties to above declared objects ( color, alpha, coordinates etc)
end
–Here, writing all local functions which are part of game logic
—given functions are example, i am defining around 15-20 more functions…have not mentioned those for the sake of clarity of reader
local function GameOver()
storyboard.gotoScene(“play”, “fade”, 1500)
end
local function monitorScore(event)
score.text = "Score: " … k
end
local function rotateobject()
object1.rotation = object1.rotation + 1
object2.rotation = object2.rotation + 1
object3.rotation = object3.rotation + 1
end
local function Restart()
–Code to restart game
end
local function Pause()
–Code to pause game
end
local function Resume()
–Code to resume game
end
function scene:enterScene(event)
PauseButton:addEventListener(“touch”, pause)
ResumeButton:addEventListener(“touch”, resume)
RestartButton:addEventListener(“touch”, resume)
Runtime:addEventListener(“enterFrame”, rotateobject)
Runtime:addEventListener(“enterFrame”, monitorScore)
end
function scene:exitScene(event)
PauseButton:removeEventListener(“touch”, pause) – just as example
ResumeButton:removeEventListener(“touch”, resume) — just as example
RestartButton:removeEventListener(“touch”, resume) — just as example
Runtime:removeEventListener(“enterFrame”, rotateobject)
Runtime:removeEventListener(“enterFrame”, monitorScore)
end
function scene:destroyScene(event)
—nothing here
end
function scene:didExitScene( event )
storyboard.removeScene( storyboard.getPrevious())
end
scene:addEventListener( “didExitScene” )
scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)
return scene[/lua]