Apologies; I’m trying to be specific but it’s hard to do without sample code 
- Yes, that’s correct. If you don’t add those objects to the scene group (or to a displayGroup that is then part of the display group, etc.) you will have to remove them manually on either willExitScene() or exitScene().
I believe you also have to manually stop physics on exit but I don’t really have much experience using the physics library.
Anything that is part of the scene object will transition with it when you go to another scene (so fade out if you use a fade, disappear if you don’t use a transition, etc) You can display.remove() these objects yourself or via the scene object, either way is fine - ie: display.remove(myObject) is the same as display.remove(scene[34])
If you want to destroy everything connected to the scene though the fastest method is to just purgeScene() on exit.
- This entirely depends on how you want the two objects to be joined. The way you have described is just a table reference ( a shortcut ). The two objects move completely independently. Which is fine, especially if you have some close relationship between them (ie: the text is the monster’s HP or something and you want a quick way to reference it).
If you want them to move together, you need to create a displayGroup instead and :insert() both objects into it.(Usually a lot of top-level displayObjects are groups, so you can expand later by adding health meters and so on to a simple sprite)
The problem you’re running into is that there is a difference between a table {} and a displayGroup(). They are both technically arrays, but displayGroups have special stage logic. That’s why you find the text object doesn’t behave right unless you insert it into the scene.
Best Method:
local monster = display.newGroup()
monster.body = monstercode -- however you build it, display.newImage, a function, etc
monster.string = textcode -- your text code, ie: display.newText
Also works, albeit differently
[code]local monster = monstercode
monster.text = textcode
local textGroup = display.newGroup()
textGroup:insert(monster.string) – now monster.string is ALSO textGroup[1]
self.view:insert(textGroup) – now all text objects in the group are part of the scene
– The monster pieces won’t move together but all of your text objects can exist and move with the scene[/code]
Usually when I build a monster I make a function like this:
[code]local function createMonster(details)
local monster = display.newGroup()
monster.hp = 100
monster.body = display.newImage(monster, “ugly.png”, 0, 0)
monster.hpDisplay = display.newText(monster, monster.hp, 0, 0)
– then set positioning of the display relative to the body
return monster
end[/code]
-
Not really sure I can help with this but a) make sure to stop/start physics yourself and b) try to use willEnter/willExit if there are timing oddities with the scene. (willEnter occurs before the scene is visible, willExit occurs before the scene is NOT visible)
-
reloadScene is the same as exit/enter I believe, but there’s no transitions. If you want it to fade-in/fade-out I think you need to use gotoScene() to another scene and then back as you suggest. [import]uid: 41884 topic_id: 35395 reply_id: 141532[/import]