You must insert the text display object into the group:
When you’re about to change scene you you pass an options table with your parameters
local options = { effect = "crossFade", time = 100, params = { score = 1000, } } storyboard.gotoScene("scene\_game", options)
And in scene_game you print the score out to a text object and insert into the group:
function scene:enterScene( event ) local group = self.view local params = event.params local scoreText = display.newText( "Score: " .. params.score, 100, 200, native.systemFontBold, 24 ) group:insert(scoreText) --code here executes every time the scene is entered regardless --of it's creation state. end
Now that it’s inserted into the group it will only appear in the scene scene_game. If you change scene the scoreText all of the objects in the display group will disappear (not deleted though).
Just to clarify, the module you took from the tutorial returns a generic object, not the display.newText() object. That generic object has a member called “scoreText” which is the disiplay.newText() object on the screen. You can’t insert generic objects into groups, only display objects.
Since you named your object “scoreText” and that object has a member named “scoreText”, then scoreText.scoreTect should have been a reference to the display.newText() object that you could insert into a group. You could have named your object billybob in which case it should have been billybob.scoreText. I’m unsure why you got that error, but it looks like you have worked past it.
You must insert the text display object into the group:
When you’re about to change scene you you pass an options table with your parameters
local options = { effect = "crossFade", time = 100, params = { score = 1000, } } storyboard.gotoScene("scene\_game", options)
And in scene_game you print the score out to a text object and insert into the group:
function scene:enterScene( event ) local group = self.view local params = event.params local scoreText = display.newText( "Score: " .. params.score, 100, 200, native.systemFontBold, 24 ) group:insert(scoreText) --code here executes every time the scene is entered regardless --of it's creation state. end
Now that it’s inserted into the group it will only appear in the scene scene_game. If you change scene the scoreText all of the objects in the display group will disappear (not deleted though).
Just to clarify, the module you took from the tutorial returns a generic object, not the display.newText() object. That generic object has a member called “scoreText” which is the disiplay.newText() object on the screen. You can’t insert generic objects into groups, only display objects.
Since you named your object “scoreText” and that object has a member named “scoreText”, then scoreText.scoreTect should have been a reference to the display.newText() object that you could insert into a group. You could have named your object billybob in which case it should have been billybob.scoreText. I’m unsure why you got that error, but it looks like you have worked past it.