function love.load()
begin_y = nil
end_y = nil
doingTouch = false
end
function love.touchpressed(id, x, y, dx, dy, pressure)
if doingTouch == false then
begin_y = y
doingTouch = true
end
end
function love.touchmoved(id, x, y, dx, dy, pressure)
end
function love.touchreleased(id, x, y, dx, dy, pressure)
end_y = y
if doingTouch == true then
if end_y < begin_y then
--do what you want if you swiped [b]up[/b]
elseif end_y > begin_y then
--do what you want if you swiped [b]down[/b]
elseif end_y == begin_y then
--do what you want if you [b]touch[/b]
end
begin_y = nil
end_y = nil
doingTouch = false
end
end
NOTE: feel free to add more features if you want, as of now it works perfectly on v11.3-Android, the best use of this code is with Talkies & Erogodic when you use choices in your visual novel
9912 wrote: ↑Mon May 24, 2021 6:17 am
Hello, i'm not very often here, but i want to share this code if someone wants an easy swipe up and down function
function love.load()
begin_y = nil
end_y = nil
doingTouch = false
end
function love.touchpressed(id, x, y, dx, dy, pressure)
if doingTouch == false then
begin_y = y
doingTouch = true
end
end
function love.touchmoved(id, x, y, dx, dy, pressure)
end
function love.touchreleased(id, x, y, dx, dy, pressure)
end_y = y
if doingTouch == true then
if end_y < begin_y then
--do what you want if you swiped [b]up[/b]
elseif end_y > begin_y then
--do what you want if you swiped [b]down[/b]
elseif end_y == begin_y then
--do what you want if you [b]touch[/b]
end
begin_y = nil
end_y = nil
doingTouch = false
end
end
NOTE: feel free to add more features if you want, as of now it works perfectly on v11.3-Android, the best use of this code is with Talkies & Erogodic when you use choices in your visual novel
tx=0
ty=0
function love.draw()
mx = love.mouse.getX()
my = love.mouse.getY()
if love.mouse.isDown(1) then
if not mouse_pressed then
mouse_pressed = true
dx = tx-mx
dy = ty-my
else
tx = mx+dx
ty = my+dy
end
elseif mouse_pressed then
mouse_pressed = false
end
love.graphics.translate(tx, ty)
-- example graphics:
love.graphics.circle( "line", 0, 0, 400 )
love.graphics.line(-440, 0, 440, 0)
love.graphics.line(0, -440, 0, 440)
end
tx=0
ty=0
function love.draw()
mx = love.mouse.getX()
my = love.mouse.getY()
if love.mouse.isDown(1) then
if not mouse_pressed then
mouse_pressed = true
dx = tx-mx
dy = ty-my
else
tx = mx+dx
ty = my+dy
end
elseif mouse_pressed then
mouse_pressed = false
end
love.graphics.translate(tx, ty)
-- example graphics:
love.graphics.circle( "line", 0, 0, 400 )
love.graphics.line(-440, 0, 440, 0)
love.graphics.line(0, -440, 0, 440)
end
That works if you have a PC/Mac with mouse/track-pad, however the code has other purpose, i'll explain:
Some day ago, i was on a personal project making a visual novel, so i took erogodic with talkies as example, however it only works with physical keyboard, and therefore PC.
I'm targeting to use on Android which uses touchscreen, thus rendering the code unusable unless swipe gestures are implemented, so i've tested some codes around here and studying the touch functions from love.graphics library.
The code i've posted aims to be usable with smartphone touchscreen and its use cases includes -but not limited to- visual novels.
Nice . Seems like I'll be using it,
though you should have probally put this in the Library and Tools section(maybe as a tool...?) or General section, cause it seems you've got it figured out and don't need much help here, in ... that is... you know...Support and Development(though I guess it seems misleading, like "hey, come and post stuff to support others here" kind of thing )
The risk I took was calculated,
but man, am I bad at math.
That works if you have a PC/Mac with mouse/track-pad, however the code has other purpose, i'll explain:
Some day ago, i was on a personal project making a visual novel, so i took erogodic with talkies as example, however it only works with physical keyboard, and therefore PC.
I'm targeting to use on Android which uses touchscreen, thus rendering the code unusable unless swipe gestures are implemented, so i've tested some codes around here and studying the touch functions from love.graphics library.
The code i've posted aims to be usable with smartphone touchscreen and its use cases includes -but not limited to- visual novels.
While you're partially correct that the given code won't detect gestures, but the mouse functions can in fact be used as a 1-touch touch input as well, if you don't want to mess with multitouch (or if the device doesn't support it).
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.