Page 1 of 1

Any experience with love.touchgestured?

Posted: Sat Dec 13, 2014 3:22 am
by norubal
Any experience with love.touchgestured? I need to detect swipe gesture in my game, so I decided to use love.touchgestured function.
But I couldn't find some good example from wiki, so I decided to find it out myself how this function work.
This is my code:

Code: Select all

function love.load()
	str = ""
end

function love.touchgestured(x, y, theta, distance, touchcount)
	str = x ..":".. y ..":".. theta ..":".. distance ..":".. touchcount
end

function love.draw()
	love.graphics.print(str)
end
I launched it from my android phone, but no result, It seems to love.touchgestured didn't called by love itself, because str was empty string after screen was touched.
If someone have experience with love.touchgestured, please share! thanks.

Re: Any experience with love.touchgestured?

Posted: Sat Dec 13, 2014 6:34 am
by slime
The event is only triggered when multiple fingers are touching the screen.

Re: Any experience with love.touchgestured?

Posted: Sat Dec 13, 2014 7:58 am
by norubal
slime wrote:The event is only triggered when multiple fingers are touching the screen.
Thank you. I have to find something another to implement swipe gesture..

Re: Any experience with love.touchgestured?

Posted: Sat Dec 13, 2014 9:34 am
by slime
You could use love.touchpressed / love.touchmoved / love.touchreleased etc. and detect the swipe by tracking the velocity (i.e. amount moved in a certain direction over a period of time) of the touch.