I’ve spent the better part of the morning optimizing the overlay modules that are ‘popping’ on-screen (removing around 50 lines of code!), and while they now works properly in the simulator, they still just ‘pop’ on-screen on my iPad Air and iPhone 4S (both 1x and 2x assets). What continues to be frustrating and perplexing is that other overlay modules display just fine.
Here’s the “create” function of one of the problem modules:
[lua]
function scene:create (e)local group = self.view propGift = display.newGroup() blackBG = display.newRect(propGift, 512, 384, 1024, 768) blackBG:setFillColor(0,0,0, overlayAlpha) giftBox = display.newImageRect(propGift, "images/overlays/gift\_box/ExtPT\_GiftOpen.png", 1024, 768) buttonInactive = display.newRect(propGift, 0, 0, 520, 520) buttonActive = display.newImageRect(propGift, "images/overlays/gift\_box/ExtPT\_GiftActive.png", 512, 512) boxTop = display.newImageRect(propGift, "images/overlays/gift\_box/ExtPT\_GiftClosed.png", 1024, 768) buttonInactive.isVisible = false; buttonInactive.isHitTestable = true buttonActive.isVisible = false local screenMidpointX = \_W \* .5 local screenMidpointY = \_H \* .5 for i=2, propGift.numChildren do propGift[i].x = screenMidpointX; propGift[i].y = screenMidpointY end exitButton = display.newImageRect(propGift, "images/UI/Close\_White.png", 40, 40) exitButton.x = \_W - 50; exitButton.y = 50 + deviceInfo.verticalOffset exitButton\_Touch = display.newCircle(propGift, exitButton.x, exitButton.y, 45) exitButton\_Touch.isVisible = false; exitButton\_Touch.isHitTestable = true boxTop:scale(deviceInfo.reductionFactor, deviceInfo.reductionFactor) giftBox:scale(deviceInfo.reductionFactor, deviceInfo.reductionFactor) buttonInactive:scale(deviceInfo.reductionFactor, deviceInfo.reductionFactor) buttonActive:scale(deviceInfo.reductionFactor, deviceInfo.reductionFactor) group:insert(propGift) end
[/lua]
And here’s the “create” function of a working module:
[lua]function scene:create (e)
local group = self.view
blackBG = display.newRect(group, 512, 384, 1024, 768)
blackBG:setFillColor(0,0,0, overlayAlpha)
if (gameState.currRoom == “rooms.int_1902_cavern”) then
pageFileExt = “_B&W.png”
end
propUninvite = display.newGroup()
propUninvite.isFlipping = false
propUninvite.hasFlipped = false
propUninvite_Back = display.newImageRect(propUninvite, “images/overlays/uninvite/UnInvite_Back” … pageFileExt, 800, 600)
propUninvite_Front = display.newImageRect(propUninvite, “images/overlays/uninvite/UnInvite_Front” … pageFileExt, 800, 600)
exitButton = display.newImageRect(propUninvite, “images/UI/Close_White.png”, 40, 40)
exitButton.x = _W - 50; exitButton.y = 50 + deviceInfo.verticalOffset
exitButton_Touch = display.newCircle(propUninvite, exitButton.x, exitButton.y, 45)
exitButton_Touch.isVisible = false; exitButton_Touch.isHitTestable = true
propUninvite_Front.x = _W / 2; propUninvite_Front.y = _H / 2
propUninvite_Back.x = _W / 2; propUninvite_Back.y = _H / 2
propUninvite_Back.xScale = .1
propUninvite_Back.isVisible = false
group:insert(propUninvite)
end[/lua]
It seems like the scene isn’t created in time before the transition actually begins. Is this possible? Why would this be the case? And why would Composer/Graphics 2.0 have a harder time creating the scene than Storyboard/Graphics 1.0, which was fine with these modules?
Thanks!