Hi all,
I’ve been testing out some code that makes a simple keypad that is supposed to change a text field to a different number depending on which key is pressed. For some reason, after about 3 or 4 keypad clicks, the screen just goes blank. Any ideas why? My test code is below:
local testGroup = display.newGroup() function test() -- Display the equation box local eqBg = display.newRect(0, 0, 200, 50) eqBg:setFillColor(140, 140, 140) eqText = display.newText( "Hello", 0, 0, native.systemFont, 36 ) eqText.x = 80 eqText.y = 34 eqText:setTextColor( 255, 255, 255 ) local padKeys = {} for i=1,9 do -- create keypad buttons padKeys["key" .. i] = display.newRect(0, 0, 36, 36) padKeys["key" .. i]:setFillColor(10, 40, 85) padKeys["key" .. i]:setReferencePoint(display.TopLeftReferencePoint) padKeys["key" .. i].myNum = i padKeys["key" .. i]:addEventListener( "touch", addKeyNumeral ) end padKeys["key1"].x, padKeys["key1"].y = 10, 52 padKeys["key2"].x, padKeys["key2"].y = 70, 52 padKeys["key3"].x, padKeys["key3"].y = 130, 52 padKeys["key4"].x, padKeys["key4"].y = 10, 110 padKeys["key5"].x, padKeys["key5"].y = 70, 110 padKeys["key6"].x, padKeys["key6"].y = 130, 110 padKeys["key7"].x, padKeys["key7"].y = 10, 170 padKeys["key8"].x, padKeys["key8"].y = 70, 170 padKeys["key9"].x, padKeys["key9"].y = 130, 170 local eqGroup = display.newGroup() eqGroup:insert( eqText ) eqGroup["eqText"] = eqText testGroup["eqGroup"] = eqGroup end function addKeyNumeral(event) if ( event.phase == "ended" ) then print ("Adding a numeral...") testGroup.eqGroup.eqText.text = event.target.myNum end return true end test()
I think it might be hardware specific though, because I just tried it on a Dell laptop and I’m not seeing objects disappear. Have you ever seen anything like this related to graphics cards or other hardware? And is there another way to check for errors other than the Terminal window? As I mentioned above, the code continues to work since I can execute other functions. It’s just that the screen goes blank.