2014-01-14 23 views
2

我有一個電暈應用程序,有兩個故事板場景(scene1.lua,addDesire.lua)。xCodeSimulator中的電暈應用程序的紫色背景

我告訴addDesire.lua爲疊加:

function onAddPurchase(event) 
    if event.phase == "ended" then 
     local options = { 
      effect = "fromBottom", 
      time = 500, 
      isModal = true, 
     } 
     storyboard.showOverlay("addDesire", options) 
    end 
end 

電暈模擬器一切正常,但在Xcode模擬器粉紅色背景出現在幾起案件。

1)addDesire.lua出現onAddPurchase後,它看起來像:

Incorrect pink background 1

當它應該看起來像:

Exptected background

2)當我關閉addDesire.lua(點擊取消按鈕)出現: Solid pink screen

也有一些是甚至陌生人在引擎蓋下回事:

addDesire.lua有2 textFields和1這是在function scene:createScene(event)創建textBox。如果我將創建這些對象的代碼註釋掉,那麼一切都很完美。

function scene:createScene(event) 
local group = self.view 

local centerX = display.contentCenterX 
local centerY = display.contentCenterY 
local _W = display.contentWidth 
local _H = display.contentHeight 

local bg = display.newImageRect("assets/dollar.png", 360, 570) 
bg:toBack() 
bg.x, bg.y = _W/2, _H/2 
bg:addEventListener("tap", function() native.setKeyboardFocus(nil); end) 
group:insert(bg) 

-- Rounded Rect Alpha 
roundedRect = display.newRoundedRect(5, 5, _W*0.9, _H*0.8, 10) 
roundedRect.x, roundedRect.y = centerX, centerY 
roundedRect:setFillColor(0/255, 0/255, 0/255, 170/255) 
group:insert(roundedRect) 
-- Label Title 
titleLabel = display.newText("Purchase", 0, 0, "AmericanTypewriter-Bold", 20) 
titleLabel.x, titleLabel.y = centerX, _H*0.15 
group:insert(titleLabel) 
-- Label Fam 
nameLabel = display.newText("Name", 0, 0, "AmericanTypewriter", 18) 
nameLabel.x, nameLabel.y = centerX, _H*0.20 
group:insert(nameLabel) 
-- Edit Fam 
nameText = native.newTextField(_W/2, _H*0.26, 240, 30) 
nameText.font = native.newFont(native.systemFont, 18) 
nameText:addEventListener("userInput", inputListener) 
group:insert(nameText) 
-- Label Name 
descriptionLabel = display.newText("Description", 0, 0, "AmericanTypewriter", 16) 
descriptionLabel.x, descriptionLabel.y = centerX, _H*0.31 
group:insert(descriptionLabel) 
-- Edit Name 
descriptionText = native.newTextBox(_W/2, _H*0.44, 240, 100) 
descriptionText.font = native.newFont(native.systemFont, 14) 
descriptionText.isEditable = true 
descriptionText:addEventListener("userInput", inputListener) 
group:insert(descriptionText) 
-- Label Deposit 
costLabel = display.newText("Cost", 0, 0, "AmericanTypewriter", 16) 
costLabel.x, costLabel.y = centerX, _H*0.57 
group:insert(costLabel) 
-- Edit Deposit 
costText = native.newTextField(_W/2, _H*0.64, 240, 30) 
costText.font = native.newFont(native.systemFont, 18) 
costText.inputType = "number" 
costText.align = "center" 
costText:addEventListener("userInput", inputListener) 
group:insert(costText) 
-- Button Save & Start game 
btnSave = widget.newButton { 
    width = _W*0.4, 
    height = 50, 
    --defaultFile = "buttonDefault.png", 
    --overFile = "buttonOver.png", 
    label = "Buy", 
    onEvent = onSaveData 
} 
btnSave.x, btnSave.y = _W/2, costLabel.y+150 
group:insert(btnSave) 
-- Button Cancel 
btnCancel = widget.newButton { 
    width = _W*0.8, 
    height = 50, 
    --defaultFile = "buttonDefault.png", 
    --overFile = "buttonOver.png", 
    label = "Cancel", 
    onEvent = onExit, 
} 
btnCancel.x, btnCancel.y = _W/2, btnSave.y+50 
group:insert(btnCancel) 


end 

這是怎麼回事?

回答