I’m also having terrible performance issues with the Samsung Galaxy S, using Samsung’s 2.2 OS.
I also have a Motorola XOOM, (Honeycomb 3.0), runs beautifully on there.
I’ve disabled almost everything in my game - all my animations, almost all my listeners, and narrowed it down to the ragdoll code. I’ve made a test application, using the ragdoll code from here:
http://developer.anscamobile.com/forum/2010/10/29/new-corona-any-radgoll-examples
You’ll need gameUI.lua, set to 60fps to really see the difference.
Just touch the white square to spawn a new ragdoll.
Galaxy S:
1 and 2 ragdolls: 60fps
3 ragdolls: 30-40fps
4 ragdolls: 30fps
On the XOOM, I can spawn over 30 and fling them all over the screen and it still runs at 60fps. The extra core can’t be doing THAT much…
And yes, my frame rate counter is a little off, but it gives you the general idea…
[lua]
local physics = require (“physics”)
local gameUI = require(“gameUI”)
local m = {}
m.floor = math.floor
m.random = math.random
physics.start ()
physics.setGravity (0, 10)
–physics.setDrawMode (“hybrid”)
–> Create Walls
local leftWall = display.newRect (0, 0, 1, display.contentHeight)
local rightWall = display.newRect (display.contentWidth, 0, 1, display.contentHeight)
local ceiling = display.newRect (0, 0, display.contentWidth, 1)
local ground = display.newRect (0, display.contentHeight - 80, display.contentWidth, 80)
physics.addBody (leftWall, “static”, {bounce = 1.0, friction = 10})
physics.addBody (rightWall, “static”, {bounce = 1.0, friction = 10})
physics.addBody (ceiling, “static”, {bounce = 1.0, friction = 10})
physics.addBody (ground, “static”, {bounce = 1.0, friction = 10})
– Create Spawn Button
local spawnButton = display.newRect(display.contentWidth * 0.5, 30, 30, 30)
spawnButton:setFillColor(255,255,255)
function spawnButton:touch (event)
if (event.phase == “ended”) then
local tempRagDoll = newRagDoll (200,100,m.random(255),m.random(255),m.random(255))
end
end
spawnButton:addEventListener ( “touch”, spawnButton )
function newRagDoll(originX, originY, r, g, b)
–> Create Ragdoll Group
local spacing = 1
local scaling = 1 – this will work for sizes of objects, not sure about joints…
local ragdoll = display.newGroup ()
local head = display.newCircle( 0, 0, 5*scaling )
head.name = “head”
head.x = originX
head.y = originY
head:setFillColor (r, g, b)
ragdoll:insert (head)
local torsoA = display.newRect( 0, 0, 14*scaling, 10.5*scaling )
torsoA.name = “torsoA”
torsoA.x = originX
torsoA.y = originY + head.height
torsoA:setFillColor (r, g, b)
ragdoll:insert (torsoA)
local torsoC = display.newRect( 0, 0, 12*scaling, 16*scaling )
torsoC.name = “torsoC”
torsoC.x = originX
torsoC.y = torsoA.y + (torsoA.height * 0.5) + spacing + 2
torsoC:setFillColor (r, g, b)
ragdoll:insert (torsoC)
local pelvis = display.newRect( 0, 0, 10*scaling, 8*scaling )
pelvis.name = “pelvis”
pelvis.x = originX
pelvis.y = torsoC.y + (torsoC.height * 0.5) + spacing
pelvis:setFillColor (r, g, b)
ragdoll:insert (pelvis)
local leftLegA = display.newRect( 0, 0, 4*scaling, 20*scaling )
leftLegA.name = “leftLegA”
leftLegA.x = pelvis.x - ((pelvis.width - leftLegA.width) * 0.5)
leftLegA.y = pelvis.y + (leftLegA.height * 0.5) + spacing
leftLegA:setFillColor (r, g, b)
ragdoll:insert (leftLegA)
local rightLegA = display.newRect( 0, 0, 4*scaling, 20*scaling )
rightLegA.name = “rightLegA”
rightLegA.x = pelvis.x + ((pelvis.width - rightLegA.width) * 0.5)
rightLegA.y = pelvis.y + (rightLegA.height * 0.5) + spacing
rightLegA:setFillColor (r, g, b)
ragdoll:insert (rightLegA)
local leftArmA = display.newRect( 125, 70, 3.5*scaling, 20*scaling ) – check these x and y values
leftArmA.name = “leftArmA”
leftArmA.x = torsoA.x - (torsoA.width * 0.5) - 1 – check this last value
leftArmA.y = torsoA.y + (leftArmA.height * 0.5) - 2 – check this last value
leftArmA:setFillColor (r, g, b)
ragdoll:insert (leftArmA)
local rightArmA = display.newRect( 185, 70, 3.5*scaling, 20*scaling ) – check these x and y values
rightArmA.name = “rightArmA”
rightArmA.x = torsoA.x + (torsoA.width * 0.5) + 1 – check this last value
rightArmA.y = torsoA.y + (rightArmA.height * 0.5) - 2 – check this last value
rightArmA:setFillColor (r, g, b)
ragdoll:insert (rightArmA)
physics.addBody (head, {bounce = 0.0, friction = 1.0})
physics.addBody (torsoA, {bounce = 0.0, friction = 1.0})
physics.addBody (torsoC, {bounce = 0.0, friction = 1.0})
physics.addBody (pelvis, {bounce = 0.0, friction = 1.0})
physics.addBody (leftLegA, {bounce = 0.0, friction = 1.0})
physics.addBody (rightLegA, {bounce = 0.0, friction = 1.0})
physics.addBody (leftArmA, {bounce = 0.0, friction = 1.0})
physics.addBody (rightArmA, {bounce = 0.0, friction = 1.0})
local neckJoint = physics.newJoint ( “pivot”, head, torsoA, torsoA.x, torsoA.y)
neckJoint.isLimitEnabled = true
neckJoint:setRotationLimits ( -22.5, 22.5 )
local backboneA = physics.newJoint ( “pivot”, torsoA, torsoC, torsoC.x, torsoC.y )
backboneA.isLimitEnabled = true
backboneA:setRotationLimits ( -22.5, 22.5 )
local backboneC = physics.newJoint ( “pivot”, torsoC, pelvis, pelvis.x, pelvis.y )
backboneC.isLimitEnabled = true
backboneC:setRotationLimits ( -22.5, 22.5 )
local leftHip = physics.newJoint ( “pivot”, pelvis, leftLegA, leftLegA.x, pelvis.y )
leftHip.isLimitEnabled = true
leftHip:setRotationLimits ( -45, 90 )
local rightHip = physics.newJoint ( “pivot”, pelvis, rightLegA, rightLegA.x, pelvis.y )
rightHip.isLimitEnabled = true
rightHip:setRotationLimits ( -90, 45 )
local leftShoulder = physics.newJoint ( “pivot”, torsoA, leftArmA, leftArmA.x, torsoA.y )
leftShoulder.isLimitEnabled = true
leftShoulder:setRotationLimits ( 0, 180 )
local rightShoulder = physics.newJoint ( “pivot”, torsoA, rightArmA, rightArmA.x, torsoA.y )
rightShoulder.isLimitEnabled = true
rightShoulder:setRotationLimits ( -180, 0 )
function ragdoll:touch( event )
gameUI.dragBody( event )
return true
end
head:addEventListener ( “touch”, ragdoll )
torsoA:addEventListener ( “touch”, ragdoll )
torsoC:addEventListener ( “touch”, ragdoll )
pelvis:addEventListener ( “touch”, ragdoll )
leftLegA:addEventListener ( “touch”, ragdoll )
rightLegA:addEventListener ( “touch”, ragdoll )
leftArmA:addEventListener ( “touch”, ragdoll )
rightArmA:addEventListener ( “touch”, ragdoll )
ragdoll.head = head
ragdoll.torsoA = torsoA
ragdoll.torsoC = torsoC
ragdoll.pelvis = pelvis
ragdoll.leftLegA = leftLegA
ragdoll.rightLegA = rightLegA
ragdoll.leftArmA = leftArmA
ragdoll.rightArmA = rightArmA
return ragdoll
end
– Create frame rate counter text
function createFrameRateCounter ()
local frameRateText = display.newText(“test”, display.contentWidth - 50, 20, native.systemFont, 16*2)
frameRateText.xScale = 0.5; frameRateText.yScale = 0.5; – Makes text sharp on Retina Display
frameRateText:setTextColor(255,255,255)
local tPrevious = 0
local tCounter = 0
local framesCounted = 0
– Displays the current frame rate
local function frameRateCounter (event)
local tDelta = event.time - tPrevious
tPrevious = event.time
tCounter = tCounter + tDelta
framesCounted = framesCounted + 1
if (tCounter > 500) then
frameRate = m.floor((framesCounted / tCounter) * 1000)
frameRateText.text = frameRate
tCounter = 0
framesCounted = 0
end
end
Runtime:addEventListener( “enterFrame”, frameRateCounter );
return frameRateText
end
local frameRateText = createFrameRateCounter ()[/lua] [import]uid: 49372 topic_id: 9133 reply_id: 34112[/import]