jeremie
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2017
08:44 AM
How to realy destroy a Panel
Hi,
I have a PanelSet and when I navigate I add some panels progressively. When I back to the first screen, in the debug console, when I use sgnodes roots I see old screens not linked to the root (and in memory ?)
what can I do to completly destroy my panels ?
best regards,
Jeremie.
I have a PanelSet and when I navigate I add some panels progressively. When I back to the first screen, in the debug console, when I use sgnodes roots I see old screens not linked to the root (and in memory ?)
function init()
m.panelset = createObject("roSGNode", "PanelSet")
m.panelset.observeField("isGoingBack","onGoBack")
m.panelset.translation = [0,0]
m.top.appendChild(m.panelset)
addScreen("HomeScreen",{})
end function
function addScreen(screenName,screenData)
m.currentScreen = m.panelset.createChild(screenName)
m.currentScreen.leftPosition = 0
m.currentScreen.observeField("mainBackground", "onChangeMainBackground")
m.currentScreen.observeField("nextScreen", "onNextScreen")
m.currentScreen.screenData = screenData
m.currentScreen.setFocus(true)
end function
function onGoBack(e)
print "on go back"
if (e.getData() = true) then
print "removing current screen"
m.currentScreen.unobserveField("mainBackground")
m.currentScreen.unobserveField("nextScreen")
end if
end function
what can I do to completly destroy my panels ?
best regards,
Jeremie.
1 REPLY 1
jeremie
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2017
09:14 AM
Re: How to realy destroy a Panel
oups, it's noob fail ^^
I used m.currentScreen but when I go back m.currentScreen is not updated. My new script is working with a screenQueue
I used m.currentScreen but when I go back m.currentScreen is not updated. My new script is working with a screenQueue
function init()
m.screenQueue = CreateObject("roArray", 0, true)
m.background = m.top.findNode("background")
m.panelset = createObject("roSGNode", "PanelSet")
m.panelset.observeField("isGoingBack","onGoBack")
m.panelset.translation = [0,0]
m.top.appendChild(m.panelset)
addScreen("HomeScreen",{})
end function
function addScreen(screenName,screenData)
currentScreen = m.panelset.createChild(screenName)
currentScreen.leftPosition = 0
currentScreen.observeField("mainBackground", "onChangeMainBackground")
currentScreen.observeField("nextScreen", "onNextScreen")
currentScreen.screenData = screenData
currentScreen.setFocus(true)
m.screenQueue.push(currentScreen)
end function
function onGoBack(e)
if (e.getData() = true) then
oldScreen = m.screenQueue.Pop()
oldScreen.unobserveField("mainBackground")
oldScreen.unobserveField("nextScreen")
end if
end function