Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Is there a way to use Ace Slide between different screens? — Gideros Forum

Is there a way to use Ace Slide between different screens?

AxlFlameAxlFlame Member
edited March 2013 in Game & application design
Hey, everyone,
I was wondering, is there a way to move between different scenes using Ace Slide? From what I've seen on the GameTemplate, you can only move between itens within the same scene.

Thanks!

Comments

  • talistalis Guru
    edited April 2013
    I don't understand fully but let me try to answer how i understood. You can use it everywhere, in different scenecontrollers also (I am guessing you have more than one scenecontroller). Just you need the reference of the scenecontroller you want to switch. That's it.

    Or in the beginning hold scenenames globally in an array than you can refer them whenever you want.

    Note: If i understood not correctly and my answer is not satisfactory please give us some more detail :D

    Likes: AxlFlame

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    @AxlFlame you can use AceSlide_oop version, which is basically used as Sprite in the scene:
    https://github.com/ar2rsawseen/AceSlide_oop

    Likes: AxlFlame

    +1 -1 (+1 / -0 )Share on Facebook
  • @talis
    Yeah, sorry for the lack of details, let me explain it a little better:

    In my game, I have game areas, each area contains 4 minigames of an specific theme.
    Each of those minigames have a selection screen that presents to the player a description of the minigame and the "Start" option.

    What I wanted is to cycle through these screens using Ace Slide. Therefore I presumed that I would have to add each screen as a element for the Slider, but in the template I was trying to use, only elements inside the current scene are added to the Slider.

    My question is if I can add different screens (scenes, from scene manager) to the Ace Slide, how could I do that?

    @ar2rsawseen I downloaded the project, but to be honest I'm kinda lost on how to implement it on my current project.
  • ar2rsawseenar2rsawseen Maintainer
    edited April 2013
    @AxlFlame
    Well in this case you could be using two approaches:
    using AceSlide
    • Create each screen as you would create separate scene (or reuse same scene, if you load data dynamically)
    • Then you need to create separate scene, where you add AceSlide as a child of this scene
    • And then add the other scenes (which are screens :) ) to the AceSlide
    using SceneManager
    • Add mouse/touch move events for dragging
    • check for specific offset and check scene with transition from right side
    Here is an example of latter approach:
    http://www.giderosmobile.com/forum/discussion/comment/17531#Comment_17531

    Likes: AxlFlame

    +1 -1 (+1 / -0 )Share on Facebook
  • AxlFlameAxlFlame Member
    edited April 2013
    So, I thought of trying the sceneManager method, but given the limitations I sorta gave up.
    @ar2rsawseen Now, I am pretty sure that the AceSlide method can help me, but when I try do put the AceSlide.lua from the AceSlide_oop project you suggested it gives me this error:

    classes/gtween.lua:69: attempt to call method 'addEventListener' (a nil value)
    stack traceback:
    classes/gtween.lua:69: in function 'staticInit'
    classes/gtween.lua:434: in main chunk

    which would be this inside the gtween.lua:
    function GTween.staticInit()
    68	GTween.shape = Shape.new()
    69	GTween.shape:addEventListener(Event.ENTER_FRAME, GTween.staticTick)
    70	GTween.time = os.timer()
    end
    What I find odd is that I don't even call the AceSlide on any other .lua, by just being in my project it causes that error... Because of that I can't even try the AceSlide method... what could be causing it?=/
  • ar2rsawseenar2rsawseen Maintainer
    @AxlFlame I actually never experienced something like this, so can't even begin to realize what might cause the problem.
    Can you share the project?
  • @ar2rsawseen Sure, it's kinda big so I'll send it to your gmail, ok?
  • Ok... I somehow found out the problem, I just don't understand why it happens...

    For some unknown reason to man, jthe problem was that I already had an class called Ace.Slide.lua on my project. Because of that, any class that I tried to create with "Ace" on the name would result in the same error.

    While over the moon about solving this I still can't figure out why it happened. I mean, I would understand if the .lua had the same name of an existing one, but it wasn't the case as far as my understanding goes.
  • So I tried implementing the AceSlide method @ar2rsawseen suggested but I think I have no idea on how to reference the scenemanager's scenes.
    Here is what I have so far:

    *Create each screen as you would create separate scene (or reuse same scene, if you load data dynamically). I used sceneManager for this:

    I have these four scenes on my sceneManager:
    ["bonecos_selection"] = bonecos_selection,
     
    ["veiculos_selection"] = veiculos_selection,
     
    ["tabuleiro_selection"] = tabuleiro_selection,
     
    ["armas_selection"] = armas_selection
    *Then you need to create separate scene, where you add AceSlide as a child of this scene
    For this step I created a scene called GeneralSelections. This is the code inside GeneralSelections.lua
    GeneralSelections = gideros.class(Sprite);
     
    function GeneralSelections:init()
     
    	local slider = AceSlide.new({
    	orientation = "horizontal",
    	spacing = 20,
    	speed = 1,
    	unfocusedAlpha = 0.75,
    	easing = nil,
    	allowDrag = true,
    	dragOffset = 10
    	})
     
    	self:addChild(slider)
     
    	slider:show()
    end
    Now, my problem is that I can't add a scene to the AceSlide... I tried the following inside GeneralSelections.lua:
    slider:add("bonecos_selection")
     
    slider:add(sceneManager["bonecos_selection"])
    but neither works... I know its probably a silly question, but how can I add these scenes?
  • ar2rsawseenar2rsawseen Maintainer
    @AxlFlame you just reference each screen by its class name.
    As in if you have
    screen1 = Core.class(Sprite)
    then you should create an instance and add like
    local scr1 = screen1.new()
    slider:add(scr1)
    I was referring as screen opposed to scene, as they won't behave like scenes, as in you manage the instances your self, not the SceneManager.

    The latter approach suggested uses SceneManager, there is also an example project to the link provided in the post ;)

    Likes: AxlFlame

    +1 -1 (+1 / -0 )Share on Facebook
  • Oh, I didn't get it at first. To be honest, since I started using Gideros, I always used sceneManager to manage transition between screens. Thus I forgot completely the usual way to do it.

    Thanks a lot, @ar2rsawseen! Works like a charm!
Sign In or Register to comment.