ok im not getting any error messages, but when i enter the screen the text hello will not go away. when i press the widget. all the text overlaps and wont go away, then when i go back to menu screen they dont disapear, the whole i dont get it, ive tried inserting the
[lua]
gamegroup:insert(object)
[/lua]
but nothing seems to work, im just curios on what i might be missing, here is the code im working with.
[lua]
local storyboard = require(“storyboard”)
local scene = storyboard.newScene()
local widget = require (“widget”)
function scene:createScene(event)
local gameGroup = self.view
local background = display.newImage(“background.jpg”)
background.x = 160
background.y = 240
background.width, background.height = display.contentWidth*0.9, display.contentHeight
local function menuTouch(event)
if event.phase == “ended” then
storyboard.gotoScene(“menuscreen”)
end
end
local list_of_things_to_say = { “alpha,beta,charlie,delta,ecko, foxtrot, kelllooooooooooooooooooooooooooooooooooooooooooo”,“hello” }
-----display text
local myText = display.newText( "hello ", 150, 200, native.systemFont, 20 )
– event handler must be defined before creating button with widget.newButton()
local function onObjectTouch( event )
if event.phase == “ended” then
if #list_of_things_to_say > 0 then
– calculate random index
local idx = math.random(1, #list_of_things_to_say)
– set the text property of your text object to the string at given index of list_of_things_to_say
myText.text = list_of_things_to_say[idx]
– remove this string from the table so that it cannot be used again
table.remove(list_of_things_to_say, idx)
else – if there’s no more things to say
myText.text = “No more things to say”
end
end
return true
end
----button
local rndmtxt = widget.newButton
{
left = 160,
top = 410,
id = “newQuestionbtn”,
label = “New question?”,
onEvent = onObjectTouch
}
local menu = widget.newButton
{
left = -25,
top = 410,
id = “menuscreen”,
label = “menu”,
onEvent = menuTouch
}
gameGroup:insert(background)
gameGroup:insert(menu)
end
function scene:enterScene(event)
end
function moveToScene()
end
function scene:exitScene(event)
end
function scene:destroyScene( event )
end
scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)
return scene
[/lua]