Deselecting tab button when entering another scene .ANSWER ASAP PLEASE

PS: i have no past of coding, and this is the first app that i have ever made so im not in a position where i can come up with solutions on my own, i just need to get past this issue of the tranistions and my app is done

help is very must appriciated thanks :slight_smile:

This tutorial might be of use to you.  It explains how storyboard manages reloading scenes:

http://www.coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/

Rob

thanks, i gave it a watch, still dont have a clue on what to do with my code to fix the problem :confused:

The image doesn’t reset itself because the scene’s view did not get re-created.  We keep your old scene around for efficiency and performance.  But this means that createScene doesn’t get called when you re-enter the scene if it already exists.  Things that have moved since you created them will be where they were last left.

There are three strategies:

  1. call storyboard.purgeScene(“scenename”) on the scene you want to reset before you go to it.   This has the effect of causing whatever goes on in your createScene() function to run again before the scene comes on the screen.  This should move all display objects created there back to their initial place.

  2. call storyboard.removeScene(“scenename”) on the scene before you go to it.  This causes the entire scene to be dumped and reloaded.  This is useful if you are initializing things or executing code that’s not inside of createScene() or enterScene() when the scene first loads.

  3. Keep the scene around, but move things to their starting location in the willEnterScene() function.  Most storyboard scene’s don’t have these extra events setup, so you would have to add the code to add the event handler in (like the ones at the bottom of your scene file).  willEnterScene() runs before the scene transitions on the screen and it’s a good place to just move things to their starting position.  This is the optimal way since it keeps your app from having to re-read every image from disk and build up the textures over and over.  Numbers 1 and 2 are the simplest (i.e. most programmer efficient, least computer efficient) ways of dealing with this. 

Rob

thanks for the explaination, it really cleared things up

im just having trouble placing the code in the right location in my code:

so for example if i have scene 1 and scene 2

and i am going from scene 2 back to scene 1, where do i place the

storyboard.purgeScene("scene2")

or

storyboard.removeScene("scene2")

(at the top or bottom of scnen 2 or do i place the code at the top of scene 1)
?

I would put it right before you do:  storyboard.gotoScene(“scene2”)

Rob

awesome thanks really helped!!! :smiley:

Any other way around this problem? (sorry for the late responses)

I’m sure you could work something else out, but I can’t thing of a better way.  The only difference is making sure to use table.maxn(tablename) instead of #tablename.  Pretty straight forward.

Rob

i tried what you said above but when i go out of the scene and into another menu and then back into that scene the image doesnt reset its self. i dont have a clue whats gone wrong/ what i need to do.

thanks for your help so far, if i can get past this problem then ive completed my app.

if anyone knows how i could fix my code please help thankyou

------function attached to button3 local myTransitions = {} leftEyeMovement = 1 local function event3(event) if leftEyeMovement == 1 then local function finishMove1() button3:setLabel("Please Press To Reset") leftEyeMovement = 2 end leftEyeMovement = 3 button:setEnabled(false) button2:setEnabled(false) myTransitions[#myTransitions + 1] = transition.to(eye2, { time = 1000, x = 30, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(leftEyeCover, { time = 1000, x = 325, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(leftEyeCover, { time = 1000, delay = 2000, x = 500, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(eye2, { time = 1000, delay = 2000, x = -30, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(eye, { time = 1000, delay = 2000, x = 30, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(leftEyeCover, { time = 1000, delay = 4000, x = -500, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(eye2, { time = 1000, delay = 4000, x = 30, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(eye, { time = 1000, delay = 4000, x = -30, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(leftEyeCover, { time = 1000, delay = 6000, x = 500, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(eye2, { time = 1000, x = -30,delay = 6000, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(eye, { time = 1000, x = 30,delay = 6000, delta = true, transition = easing.outQuad, onComplete = finishMove1 }) end if leftEyeMovement == 2 then local function finishMove2() button:setEnabled(true) button2:setEnabled(true) leftEyeMovement = 1 end leftEyeMovement = 3 myTransitions[#myTransitions + 1] = transition.to(leftEyeCover, { time = 1000, x = -825, delta = true, transition = easing.outQuad }) myTransitions[#myTransitions + 1] = transition.to(eye, { time = 1000, x = -30, delta = true, transition = easing.outQuad, onComplete = finishMove2 }) button3:setLabel("Alternate Test") end end button3 = widget.newButton{ label = "Alternating Test", fontSize = 30, width = 640, height = 90, left = 0, top = 750, onRelease = event3 } --------insert every button and image to group bellow group:insert( bg ) group:insert( eye ) group:insert( eye2 ) group:insert( sockets ) group:insert( button ) group:insert( button2 ) group:insert( button3 ) group:insert( rightEyeCover ) group:insert( leftEyeCover ) group:insert( backButton ) group:insert( infoButton ) end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view -- do nothing end -- Called when scene is about to move offscreen: function scene:exitScene( event ) for i = table.maxn(myTransitions), 1, -1 do if myTransitions[i] then transition.cancel(myTransitions[i]) myTransitions[i] = nil end end local group = self.view

PS: i have no past of coding, and this is the first app that i have ever made so im not in a position where i can come up with solutions on my own, i just need to get past this issue of the tranistions and my app is done

help is very must appriciated thanks :slight_smile:

This tutorial might be of use to you.  It explains how storyboard manages reloading scenes:

http://www.coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/

Rob

thanks, i gave it a watch, still dont have a clue on what to do with my code to fix the problem :confused:

The image doesn’t reset itself because the scene’s view did not get re-created.  We keep your old scene around for efficiency and performance.  But this means that createScene doesn’t get called when you re-enter the scene if it already exists.  Things that have moved since you created them will be where they were last left.

There are three strategies:

  1. call storyboard.purgeScene(“scenename”) on the scene you want to reset before you go to it.   This has the effect of causing whatever goes on in your createScene() function to run again before the scene comes on the screen.  This should move all display objects created there back to their initial place.

  2. call storyboard.removeScene(“scenename”) on the scene before you go to it.  This causes the entire scene to be dumped and reloaded.  This is useful if you are initializing things or executing code that’s not inside of createScene() or enterScene() when the scene first loads.

  3. Keep the scene around, but move things to their starting location in the willEnterScene() function.  Most storyboard scene’s don’t have these extra events setup, so you would have to add the code to add the event handler in (like the ones at the bottom of your scene file).  willEnterScene() runs before the scene transitions on the screen and it’s a good place to just move things to their starting position.  This is the optimal way since it keeps your app from having to re-read every image from disk and build up the textures over and over.  Numbers 1 and 2 are the simplest (i.e. most programmer efficient, least computer efficient) ways of dealing with this. 

Rob

thanks for the explaination, it really cleared things up

im just having trouble placing the code in the right location in my code:

so for example if i have scene 1 and scene 2

and i am going from scene 2 back to scene 1, where do i place the

storyboard.purgeScene("scene2")

or

storyboard.removeScene("scene2")

(at the top or bottom of scnen 2 or do i place the code at the top of scene 1)
?

I would put it right before you do:  storyboard.gotoScene(“scene2”)

Rob

awesome thanks really helped!!! :smiley: