Usually when I create something, I try to make it as configurable and reusable as possible. So I could use it in further projects and share it with others.
This is exactly the case. My feedback team voted, that package and level selecting system we had, wasn't good enough, so I created something more sophisticated, which maybe could be even used for other things. And I wanted to share it with all of you.
Basically it's an object slider, which have functions to slide to specific objects and even allows to switch between objects by draging them.
Here is a quick snippet for usage:
--initialize slider
AceSlide.init({
orientation = 'vertical',
spacing = 100,
parent = stage,
speed = 5,
unfocusedAlpha = 0.75,
easing = nil,
allowDrag = true,
dragOffset = 10
})
--create 10 boxes
for i = 1, 10 do
local box = Bitmap.new(Texture.new('images/crate.png'))
box:setScale(2)
AceSlide.add(box)
end
--display slider
AceSlide.show() |
And you can find project with all dependencies and demonstration video here:
http://appcodingeasy.com/Gideros-Mobile/Easy-input-for-choosing-packages-or-levels-in-Gideros-MobileFeel free to use and modify
Comments
@atilim, can you explain the order of the event dispatch?
I try this
button:addEventListener(Event.MOUSE_UP, function(event) print("hello")
event:stopPropagation()
end)
button:addEventListener("click",
function()
click = click + 1
label:setText("Clicked " .. click .. " time(s)")
print("clicked")
end)
it seems the onMouseUp function in the button.lua is called first,but in @ar2rsawseen 's
AceSlide, it seems the onMouseUp function in the button.lua is called after the onMouseUp in Ace.Slide.lua so the click callback will not be called if drag and moved.
https://sites.google.com/site/xraystudiogame
@atilim,could you explain that for us?
https://sites.google.com/site/xraystudiogame
fixed some bugs with dragging and buttons. For example, when dragging it set focus true to button, but on mouse up if it was dragged I stop propagation, so focus true was never removed and strange things happend, like selecting last dragged box and not the clicked one.
Now traversing all objects to look if it is button and removing focus from them, seems to work fine.
did you update the code on your site??
I download it and the bug above still exist.
https://sites.google.com/site/xraystudiogame
Well atleast I thought I had. I've reuploaded it now.
But you can also check Game Template: http://appcodingeasy.com/Gideros-Mobile/Gideros-Mobile-Game-Template
It uses same slider with Button class, so you can check there if it works for you.
I have modified the code myself,and it work well now.
https://sites.google.com/site/xraystudiogame
I just get the item on mousedown and call a deselect function on the item on mouseup.
https://sites.google.com/site/xraystudiogame
But most important, that you got it working
You did a great job.
I think the function findClosest can be improved a little, I'm afraid it is not so efficient for large list.
https://sites.google.com/site/xraystudiogame