function Star:new(inputColor) local star = display.newGroup() star.name = "star" star.objectType = "star" star.x = math.random() \* W star.y = math.random() \* H star.starImage = display.newImage("Assets/star.png") if inputColor == "purple" then purpleStarGroup:insert(star) star.starImage:setFillColor(194/255, 52/255, 155/255) purpleStarGroup.movement = transition.moveBy(purpleStarGroup, {y=H, time=10000}) elseif inputColor == "gray" then grayStarGroup:insert(star) star.starImage:setFillColor(149/255, 149/255, 149/255) grayStarGroup.movement = transition.moveBy(grayStarGroup, {y=H, time=15000}) else whiteStarGroup:insert(star) whiteStarGroup.movement = transition.moveBy(whiteStarGroup, {y=H, time=20000}) end star.color = inputColor star:insert(star.starImage) star:toBack() --Physics -- local starCollisionFilter = { categoryBits = bitTable.star, maskBits = bitTable.screen} -- local starBodyElement = { filter=starCollisionFilter } -- physics.addBody( star, "dynamic", starBodyElement) -- star.isSensor = true return star end local function initParallax() for i = 1, 50, 1 do Star:new("purple") Star:new("gray") Star:new("white") end return true end
I am using this code to make a parallax space kind of background for my game. The app runs fine on the Corona Simulator and on my iPhone 5C. My app has no memory leaks (in fact it never goes over 1kb of memory use) and I have narrowed the background is causing my app to significantly slow when I run on my Samsung Galaxy Tab2 and Amazon Kindle Fire 1st Gen running Android. When I comment out the background, everything else in my app runs flawlessly at 60FPS, but leaving the background in causes the frame rate to drop to ~25-30 with no uptick in memory usage or texture memory usage. My config.lua file treats Android devices different than iPhone devices in terms of their screen size, everything else is constant. What could be causing this?