it's kind different thing. I'm just trying to understand how to add event on a gesture. Something like set x=0 when mousedown, then track mousemove. And if x=-50 then self.pageNo = self.pageNo - 1 and if x=50 then self.pageNo = self.pageNo + 1
Set allowRotation and inverseShape to false and add two gestures with (0,0)(0,50) points and vice versa (50,0)(0,0) . And add callback to each gesture to go to next or previous scene
and here's a simple bit of code. (I don't think this would make it into any final code because it is so simple, but hopefully it illustrates a concept)
local isMouseDown =falselocal originalMousePosition ={x=0, y=0}--I only use x, not y function onMouseDown(event)--only do page turn at edges of page--assuming a page width of 320 hereif event.x <100or event.x >220then
isMouseDown =true
originalMousePosition.x = event.x
endendfunction onMouseMove(event)--only track back swipe on the left of the screen--and a forward swipe on the right of the screenif isMouseDown thenif originalMousePosition.x <100and event.x <(originalMousePosition.x - 50)thenprint("Should go back a page here")
isMouseDown =falseendif originalMousePosition.x >220and event.x >(originalMousePosition.x + 50)thenprint("Should go forward a page here")
isMouseDown =falseendend--note if you want not to record a gesture that goes in the wrong direction in the middle--then you need to track currentMousePosition.x and if it goes the --wrong way, then set isMouseDown = false to stop the onMouseMove page turnendfunction onMouseUp(event)
isMouseDown =falseend
stage:addEventListener(Event.MOUSE_DOWN, onMouseDown)
stage:addEventListener(Event.MOUSE_MOVE, onMouseMove)
stage:addEventListener(Event.MOUSE_UP, onMouseUp)
thanks. If there are somebody as much stupid as i am, i can bring my solution(because i just can't understand how "callback" works). You can inverse how button works. So make your buttons tall(to fit screen) and make them totally transparent. Then change what buttons do. Originally onMouseUp turn pages if self.focus=true, but you should make call Event.new("click") on self.focus=false.
I know that it's not brilliant, but it is very easy and may be it can help somebody. And it works.
@mysps the buttons added to the screen on scenecontroller.lua . If you want to remove them you need to change the logic of the code a little bit. You need to handle onenterscene of page0 and remove the required button there. And onexit of the scene you need to add it again to the stage.
If i will go home early today i will try to write it for you how it will be coded
Comments
http://www.giderosmobile.com/forum/discussion/453
http://www.giderosmobile.com/forum/discussion/693/can-gideros-recognize-gestures
Set allowRotation and inverseShape to false and add two gestures with (0,0)(0,50) points and vice versa (50,0)(0,0) . And add callback to each gesture to go to next or previous scene
http://www.giderosmobile.com/documentation/events.html
and here's a simple bit of code. (I don't think this would make it into any final code because it is so simple, but hopefully it illustrates a concept)
If there are somebody as much stupid as i am, i can bring my solution(because i just can't understand how "callback" works).
You can inverse how button works. So make your buttons tall(to fit screen) and make them totally transparent. Then change what buttons do. Originally onMouseUp turn pages if self.focus=true, but you should make call Event.new("click") on self.focus=false.
I know that it's not brilliant, but it is very easy and may be it can help somebody. And it works.
Then any size will be ok.
---------------------------------------
When I try to download the template, my computer only sees an icon. It does not find the file. Any suggestions?
Thank you.
I've uploaded it here: http://appcodingeasy.com/Gideros_Ebook_Template.zip
you can try downloading from it
i've played around and removed the code but not sure where in the scene controller where to make the change.
If i will go home early today i will try to write it for you how it will be coded