You should use an on touch event, then check to see if the the movement is going right over time, eg start a counter, if the event x is moving a specific delta or more and it has done it for x consecutive events then it's it's a swipe to the right.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
After adding Gestures class in your project the code is so simple to use with Scenemanager. Add this code snippet to all your secenes to the init function.
localfunction callback(name)if name=='Backward'then--Your code when it is backward swipe--You can change scene for example if you wantelse--Your code when it is forward swipe--You can change scene for example if you wantendendlocal gest = Gestures.new({debug=true,
draw =false,
drawColor = 0xff0000,
drawWidth =5,
autoTrack =true,
scope = self,
allowRotation =false,
inverseShape =false,
points =33})
gest:addGesture('Forward', {{x =0, y =0},
{x =0, y =50}}, callback)
gest:addGesture('Backward', {{x =50, y =0},
{x =0, y =0}}, callback)
Thank you, but (and I apologize again if this is a stupid question) I changed LevelSelectScene to stage (assuming that was the right thing to do because I don't have anything called that in my game) and nothing happens. I know I'm missing something, if someone could point me in the right direction I would really appreciate it!! Thanks so much!
PS: I'm not using the swipe to change scenes or whatever, I'm just using it to activate a "boost" on my character... if that matters at all...?
You need to learn about the whole self thingy. self is used within classes to refer to the particular instance of a class. Maybe this tiny example might serve to help..
Thing = Core.class()function Thing:init()
self.name ="thing"-- this things nameprint(self.name .. " created")endfunction Thing:update()print(self.name .. " updated")endlocal myThing = Thing.new()-- make a new instance of thing
myThing:update()-- will print the things name
I need to improve my skills at explaining stuff I think
Comments
https://deluxepixel.com
Fragmenter - animated loop machine and IKONOMIKON - the memory game
http://appcodingeasy.com/Gideros-Mobile/Detecting-Gestures-in-Gideros
Likes: oleg
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Add this code snippet to all your secenes to the init function.
I added the Gesture.lua file to my project and added in the above code to my main.lua.
I added in a
Did I do something wrong?
Thanks!
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
I know I'm missing something, if someone could point me in the right direction I would really appreciate it!!
Thanks so much!
PS: I'm not using the swipe to change scenes or whatever, I'm just using it to activate a "boost" on my character... if that matters at all...?
listeners added?
stage:addEventListener(Event.MOUSE_DOWN, self.onMouseDown, self)
stage:addEventListener(Event.MOUSE_UP, self.onMouseUp, self)
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
My code is as follows:
And thanks for the mini lesson! New to Gideros so that was really helpful!
Likes: antix
Fragmenter - animated loop machine and IKONOMIKON - the memory game