I’m developing a game (fairly simple with a couple of screens and a few sprites) mainly for iOS but yesterday I decided to test it on an actual Android device (Nexus One) and there’s a significant loss in performance compared to testing on an iPod touch.
I’m talking about 500-900 millisecond response time when the screen is tapped on Android compared to instant response on iOS. In addition, when I use logcat to see what’s going on, it outputs things about “Grow Memory Heap”.
Hi seanh, the structure of my project goes like this:
Main menu
Play
Game Screen
Screen has one background image
There’s an init() method that creates the initial 4 enemy sprites and adds them to a table (enemyArray)
The sprites have 4 frames each and they animate at about 600ms, and they contain an event listener on 'tap
There’s the game loop that moves the sprites and checks if they’re “dead” and should be removed
[lua]-- Function when the sprite is ‘tapped’
local killEnemy = function( event )
if event.phase == ‘began’ then
local target = event.target
target.taps = target.taps + 1
if(target.taps >= target.tapsToKill) then
target.isDead = true
end
end
end
– Main game loop
local gameLoop = function( event )
for i,obj in pairs(enemyArray) do
if obj.isDead == true then
table.remove(enemyArray, i)
obj:removeSelf()
else
obj.x = obj.x + 0.10
end
if obj.x > display.contentWidth then
obj.isDead = true
end
end
…
end[/lua]
I’m using the latest Corona Game edition by the way.
There’s another case where the # of screen updates increase when the screen is touched, but it sounds like this is different. I’ll link this to that one so we look at them at the same time. [import]uid: 54 topic_id: 3319 reply_id: 10196[/import]
tjackiw, Would you mind sharing what you did to rearrange your code, so that others could learn what to avoid for android builds? I’ve tried building several of the sample projects for android and all the physics samples were dreadfully slow on my TMobile MyTouch. [import]uid: 11021 topic_id: 3319 reply_id: 11854[/import]
Greg, nothing really specific to report, I just re-factored the way I was doing the main game loop and that seemed to fix the lag during gameplay on a Nexus one. [import]uid: 8446 topic_id: 3319 reply_id: 11932[/import]