Text for my Scene One goes to my Scene Two!!! Trouble!!!

Dear all,
May I ask a very basic question here?
My inserted some texts for my Scene One; however, when I went to my next scene, those texts also appeared there. This is not what I want. Could anyone here tell me how to fix the problem?
Thanks in advance,
Henry [import]uid: 150748 topic_id: 28300 reply_id: 328300[/import]

This will happen if you did not insert your text object into your scene’s display group…therefore when you leave the scene and the display group is removed from memory, the text object is left behind.

If you’re using storyboard, and are creating the text within createScene, insert this line after setting up the text:

group:insert(myText)

[import]uid: 93133 topic_id: 28300 reply_id: 114319[/import]

Nick,
I see…
Thank you so much for your advise, Nick.
Yes, it makes perfect sense!
Warm regards,
Henry [import]uid: 150748 topic_id: 28300 reply_id: 114321[/import]

and if you’re using Director, it would be:
localGroup:insert(myText)

[import]uid: 19626 topic_id: 28300 reply_id: 114323[/import]

Hi Nick,
I have tried, but it didn’t work. I suppose something wrong with my code.
Could you tell me where the problem is?
Regards,
Henry

module (…, package.seeall)
local red = storyboard.newScene (“red”)
function red:createScene( event )
local localGroup:insert(myText)
local localGroup = self.view
[import]uid: 150748 topic_id: 28300 reply_id: 114324[/import]

Thank you, Mr Miracle,
I use Storyboard. :slight_smile:
(Just converted to Storyboard two weeks ago.)
Regards,
Henry [import]uid: 150748 topic_id: 28300 reply_id: 114325[/import]

Remove the word “local” in both of the last lines. It’s already been declared, so declaring another local localGroup would be specific to that function only. [import]uid: 6084 topic_id: 28300 reply_id: 114326[/import]

So, it should be…???

module (…, package.seeall)
local red = storyboard.newScene (“red”)

function red:createScene( event )
localGroup:insert(myText)
localGroup = self.view [import]uid: 150748 topic_id: 28300 reply_id: 114327[/import]

You need to insert the text after creating the reference to self.view:

[lua]module (…, package.seeall)
local red = storyboard.newScene (“red”)
local myText – allows you to reference myText from outside createScene, i.e. change the text, colour, or move it.

function red:createScene( event )

local localGroup = self.view

myText = display.newText(“Some Text”, 0, 0, native.systemFont, 16)

localGroup:insert(myText)

end[/lua] [import]uid: 93133 topic_id: 28300 reply_id: 114328[/import]

Thank you, Nick!
:slight_smile: [import]uid: 150748 topic_id: 28300 reply_id: 114329[/import]