Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Modifying ar2rsawseen's great slider code? - Gideros Forum

Modifying ar2rsawseen's great slider code?

DaveyJJDaveyJJ Member
edited February 2012 in General questions
Hi all,

As a newbie programmer (designer of 20+ years) I can manage only fairly rudimentary Lua and JS coding. Enough to get myself into trouble, sometimes make things work, but still need to remind myself daily how to write a loop. ;)

I managed to get into ar2rsawseen's superb Ace.slide code, and actually write a loop to slide horizontally through four images, which is a big deal for me.

AceSlide.init({
orientation = "horizontal",
spacing = 0,
parent = stage,
speed = .5,
unfocusedAlpha = 1.0,
easing = inCubic,
allowDrag = true,
dragOffset = 70
})

local cover = {"image-1.jpg","image-2.jpg","cimage-3.jpg","image-4.jpg"}

for i = 1, 4 do
local images = Bitmap.new(Texture.new(cover[i]))
AceSlide.add(images)
end

My question is about a "multi-layer" series of images that needs to swipe/scroll both horizontally through a row, and also swipe/scroll up/down vertically down to the next/previous series. I'll pseudo-code it to show you what I mean ...

local cars = {
{"ford-1.jpg, "ford-2.jpg", "ford-3.jpg" ... "ford-n.jpg"}
{"gm-1.jpg, "gm-2.jpg", "gm-3.jpg" ... "gm-n.jpg"}
}

So the screen initially shows ford-1, move right shows ford-2, the down arrow would show gm-1 (preferably going to the start of the next row, instead of gm-2), etc.

Is is somehow possible to have the AceSlide.init work for both directions, depending on which arrow or swipe the user does? Can anyone help me with this (it's probably not as easy as I imagine)?

Dislikes: roboward

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

Comments

  • Hello,

    In my humbled opinion, it would be easier to write new a new class.

    I have one idea though, that might work almost as you want. For horizontal you create Ace.Slide, but for vertical you simply change scene to new horizontal Ace.Slide, which will go to first element in row.

    Will that work for you?

    Likes: DaveyJJ

    +1 -1 (+1 / -0 ) Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    edited February 2012
    I've probably have too much free time, or I'm simply just love coding, but I threw together an example of what I've meant.

    And here is the video, just if someone is interested in something similar:
    zip
    zip
    MultiSlider_v2.zip
    127K
    +1 -1 (+3 / -0 ) Share on Facebook
  • DaveyJJDaveyJJ Member
    edited February 2012
    Yes, I like the idea of simply changing scenes if it's a vertical swipe. But I assume it wouldn't be sliding transition? I'm still working through how to set up multiple scenes, btw (I am no programmer) ... those would be separate .lua files? main.lua is "ford", gm.lua is GM, etc? Many thanks, btw. If *I* managed to get this far with your code, you've put something out that was really well thought through.
  • I've probably have too much free time, or I'm simply just love coding, but I threw together an example of what I've meant.
    Wow, this is so kind. I too, devote too much time to stuff I love to do. I'm going to try to make heads or tails out of it and will post my results. Thank you so much for the effort and contribution.

    Likes: gorkem

    +1 -1 (+1 / -0 ) Share on Facebook
  • DaveyJJDaveyJJ Member
    edited February 2012
    Works perfectly, Arturs. As easy to understand as your previous posting, many thanks. I can't see how to get the swipe working with a up/down swipe to change scenes (only the buttons) but it works perfectly and very very fast. Thank you so much!!
  • Well swiping might be a problem, because Ace.Slide overrides mouse move event and stops event propagation.

    Nevertheless I've updated project files attached to my previous comment, with vertical swiping functionality, but as I said Ace.Slide overrides its and Swiping works only "outside the box".

    You may want to try to out some design element like "swipe line", to show users, that they can swipe outside the image, or comment out "event:stopPropagation()" in Ace.Slide onMouseMove and onMouseUp methods and try to find apropriate dragOffset parameter value not to trigger horizontal slide while swiping vertical one.

    But doing that also might cause some bugs if you use images as buttons, meaning they also need to receive mouse events. Well just need to experiment around and see. ;)
Sign In or Register to comment.