Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Page Swap With Ace.Slide — Gideros Forum

Page Swap With Ace.Slide

talistalis Guru
edited July 2012 in Code snippets
Ok i saw @ar2rsawseen Ace.Slide code and thought that why not to use it in ebook template as a page swap property in the down with page numbers.

The numbers are automatically generated according to how many scenes you will be adding to your Scenemanager.

Hope it will be helpful to someone.

The project is in the attachment. And here is some screenshot also.

I just make it fastly so it is not so much user friendly. It is swapping pages on by one.

Improvements in my mind:
There will be a hidden "Go"(alpha=0) button. When user slides to page the scene will not change only hidden "GO" button will be visible(alpha=1) then user can slide fastly through page numbers and can go if he\she wanted.

Better but diffucult idea:
Another idea is with timer. There will be no hidden "Go" button if the user will stay more than 5 seconds without sliding the page numbers the scene will jump to the scene.

Likes: ar2rsawseen

Dislikes: paulgr, troysandal

+1 -1 (+1 / -2 )Share on Facebook

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Really nice one.

    I've actually rewrote this class a bit, because when I was creating it, I wasn't fully aware of Gideros class options so I created it as a standard lua module, but now it will be Gideros class compatible and released with new game template.

    It has all the same API, so it will be easy to integrate with existing projects ;)
  • thanks, actually what i want to do is to make it compaitable like an object. Now i just edited your code.
    It can be something like this

    PageNumbers.init({
    orientation = 'horizontal',
    spacing = 100,
    parent = stage,
    speed = 5,
    unfocusedAlpha = 0.75,
    easing = nil,
    font = "Roboto.ttf",
    fontsize = "18"
    --......
    --And more properties like this:)
    })
  • ar2rsawseenar2rsawseen Maintainer
    Here's a new version using Gideros class system

    And usage is quite similar:
    --create slider
    	local slider = Slider.new()
    	self:addChild(slider)
    	--loop through packs
    	for i, value in ipairs(packs.packs) do
    		--create group
    		local group = Sprite.new()
     
    		--get pack picture
    		local box = Button.new(Bitmap.new(Texture.new("images/crate_locked.png", conf.textureFilter)), Bitmap.new(Texture.new("images/crate_locked.png", conf.textureFilter)))
     
    		group:addChild(box)
     
    		slider:add(group)
    	end
    	--show Ace slide
    	slider:show()
    If you want to make it as reusable object, I'd suggest you trying to use Gideros class system.

    In your case, each scene could be a PageNumber object inherited from sprite, with it's own ID (page number). And then you add them to scene manager.

    zip
    zip
    Slider.zip
    0B
  • hmm never used it but gonna look from your example, thanks again.
  • loves_oiloves_oi Member
    edited July 2012
    Here's a new version using Gideros class system

    And usage is quite similar:
    --create slider
    	local slider = Slider.new()
    	self:addChild(slider)
    	--loop through packs
    	for i, value in ipairs(packs.packs) do
    		--create group
    		local group = Sprite.new()
     
    		--get pack picture
    		local box = Button.new(Bitmap.new(Texture.new("images/crate_locked.png", conf.textureFilter)), Bitmap.new(Texture.new("images/crate_locked.png", conf.textureFilter)))
     
    		group:addChild(box)
     
    		slider:add(group)
    	end
    	--show Ace slide
    	slider:show()
    If you want to make it as reusable object, I'd suggest you trying to use Gideros class system.

    In your case, each scene could be a PageNumber object inherited from sprite, with it's own ID (page number). And then you add them to scene manager.

    i copied and pasted your slider code example to Gideros. But it didn't work.I'm taking this error :
    deneme.lua:2: attempt to index global 'Slider' (a nil value)
    stack traceback:
    deneme.lua:2: in main chunk

    Why? I want to do a simple slider only. What do i have to do?
    Thanks in advance
  • ar2rsawseenar2rsawseen Maintainer
    Did you include Slider.lua from attachement of my last post to project?
  • loves_oiloves_oi Member
    edited July 2012
    @ar2rsawseen i downloaded the zip but it is broken and it cannot be extracted.
  • ok . i copied and pasted the Slider.lua
    And it's my main.lua:
    --create slider
    	require("Slider")
    	local slider = Slider.new()
    	self:addChild(slider)
    	--loop through packs
    	for i, value in ipairs(packs.packs) do
    		--create group
    		local group = Sprite.new()
     
    		--get pack picture
    		local box = Button.new(Bitmap.new(Texture.new("man.png", conf.textureFilter)), Bitmap.new(Texture.new("man.png", conf.textureFilter)))
     
    		group:addChild(box)
     
    		slider:add(group)
    	end
    	--show Ace slide
    	slider:show()
    But i'm still taking error. It's :
    main.lua:4: attempt to index global 'self' (a nil value)
    stack traceback:
    main.lua:4: in main chunk
  • ar2rsawseenar2rsawseen Maintainer
    well I used self:addChild(slider) but you can change it depending on what you are using.

    for example stage:addChild(slider)
  • loves_oiloves_oi Member
    edited July 2012
    well I used self:addChild(slider) but you can change it depending on what you are using.
    I couldn't understand what you write in the code. It's difficult to me :( I'm just a beginner now and i have to make a simple slider only. What should i do ?? I changed self:addChild(slider) with stage:addChild(slider) . But it gives the error:
    main.lua:6: attempt to index global 'packs' (a nil value)
    stack traceback:
    main.lua:6: in main chunk
    Thanks for your participation.
  • loves_oiloves_oi Member
    edited July 2012
    Could anybody help me? Or show a way of doing it? What should i do inside for loop
    for i, value in ipairs(packs.packs) do
    		--create group
    		local group = Sprite.new()
     
    		--get pack picture
    		local box = Button.new(Bitmap.new(Texture.new("man.png", conf.textureFilter)), Bitmap.new(Texture.new("man.png", conf.textureFilter)))
     
    		group:addChild(box)
     
    		slider:add(group)
    	end
    What is 'packs.packs'
    Where should i use 'value' and 'i' . What is the table to use inside ipairs.
    I want to make a simple slider.
    Thanks for all help.
  • @loves_oi can you please download this project totally do not copy paste anything just download it and open from gideros studio.
    http://appcodingeasy.com/Gideros-Mobile/Easy-input-for-choosing-packages-or-levels-in-Gideros-Mobile
    This project is running like a charm without errors.
    After it try to understand and change the code one step at a time.
  • OH yes! I'm glad to see this really works :) Thank you very very very much :) It will be really useful for me.
    1.I have just started to try understanding the code.But where should i start to analyse the overall code . When i start from main.lua , everything will look like easy. But when i got deeper into the code , - class folders , Ace.Slide.lua , Slider.lua , settings etc. - everything will be very complex and inconceivable .

    2.For another example , i looked at button example which comes with Gideros studio examples.I understand the main.lua. But button.lua is inconceivable. What should i do? Which file should i understand ? main file or button.lua ?

    Masters , Give me more advise please ...

    Thank for everything, helpful Gideros Family!
  • @loves_oi sorry can't believe I missed your post

    Well best way to learn, for me at least, is to try to create your own component.

    Imagine one Slider, or something similar, or completely different, on component that you need or want to create and try it. And we will be here to navigate you, advice, etc ;)

    Best way to learn is to try it yourself
Sign In or Register to comment.