Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Quick scene transitions fail? — Gideros Forum

Quick scene transitions fail?

bigtunacanbigtunacan Member
edited March 2016 in General questions
I am using SceneManager and WidgetCandy where I will have the scene transition when the user clicks a button.

I'm getting some odd behavior where if a user clicks on a button very quickly after a scene has transitioned in then the transition to the next scene fails.

Here is an example of a button that triggers such a scene transition. The existing widgets will be removed, but the scene transition to the "select" scene never occurs. If the user waits a couple of seconds after this "login" scene has been transitioned into and then clicks this button then the "select" scene transitions in correctly.

I suspect that what is happening is that the current scene has not completed the transition in and this is causing an issue, but I'm not sure what is the proper way to handle this.
_G.GUI.NewButton(
		{
			name = "LoginButton",
			x = "auto",
			y = "auto",
			width = "100%",
			parentGroup = "LoginWindow",
			theme = "theme_1",
			caption = "Login",
			textAlign = "center",
			--icon = 15,
			onRelease = function() 
				print("We are here")
				_G.GUI.RemoveAllWidgets()
				sceneManager:changeScene("select", conf.transitionTime, conf.transition, conf.easing)
			end,
		}
	)

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited March 2016
    if a user clicks on a button very quickly after a scene has transitioned in then the transition to the next scene fails.
    So it seems you try to changeScene before previous scene have ended.

    Scenemanager has some scene transition events:
    enterBegin: Dispatched when your new scene is about to enter the stage. You can initialize your variables here.
    enterEnd: Dispatched after the transition of new scene has ended. Mostly, you add listeners and start your logic here.
    exitBegin: Dispatched when your current scene is about to leave the stage. You can remove listeners and stop timers here.
    exitEnd: Dispatched after your current scene has leaved the stage.

    http://appcodingeasy.com/Gideros-Mobile/Manage-Scenes-in-Gideros-Mobile

    So I can suggest to add UI element on enterEnd, when transition of current scene have ended, so user would be able to click the button only then
    Level = Core.class(Sprite)
     
    function Level:init()
        --listen to scene event
        self:addEventListener("enterEnd", self.onEnterEnd, self)
    end
     
    --scene finished transitioning
    function level:onEnterEnd()
        --ad ui elements here
    end

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    edited March 2016
    Since you are using Widget Candy the example that @ar2rsawseen provided could be expanded a little. You just need to create your button with it's enabled property set to false and then enable it when the scene has finished transitioning in.
    Level = Core.class(Sprite)
     
    function Level:init()
        --listen to scene event
        self:addEventListener("enterEnd", self.onEnterEnd, self)
    end
     
    --scene finished transitioning
    function level:onEnterEnd()
        _G.GUI.Enable("LoginButton") -- ENABLE BUTTON
    end
  • Thank you both. This is what I needed. I like the the option you have suggested antix so I can display the UI right away is lessing jarring, but keep it disabled until the transition is finished.

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    edited March 2016
    Glad to help. Generally you would want lock all widgets until the transition has completed. You could modify the Widget Candy code to add such functionality..

    Near the top of the code you would add a new variable to signify if all widgets are locked or unlocked
    V.locked = false
    Then you would introduce a new function to set all widgets locked/unlocked
    V._lock = function (state)
      V.locked = state
    end
    Finally you would modify the existing touch listening functions to do nothing if all widgets are locked.
    V._OnWidgetTouch = function (target, event)
      if V.locked then return end
      -- OTHER CODE
    end
     
    V._OnWindowTouch = function (target, event)
      if V.locked then return end
      -- OTHER CODE
    end
     
    V._OnWindowDrag = function (target, event)
      if V.locked then return end
      -- OTHER CODE
    end
     
    V._OnWindowClose = function (target, event)
      if V.locked then return end
      -- OTHER CODE
    end
    Now in your enterBegin function you can lock all widgets
    function level:onEnterBegin()
        _G.GUI.lock(true) -- DISABLE ALL WIDGETS
    end
    And in your exitBegin function you can then unlock all the widgets again
    function level:onEnterBegin()
        _G.GUI.lock(false) -- ENABLE ALL WIDGETS
    end
    I think that should do it ~:>
  • @antix, didn't see your reply earlier. This is a great idea; I'm definitely going to add this into my project.

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    Cool. Let me know if it works since I haven't tested it :)
Sign In or Register to comment.