A small library i created recently to test some basic games on android devices
I will be adding more features to this in the future, but thought this could help someone as it is:
https://github.com/Jigoku/paddy
Basically, it draws a dpad to the screen which you can use to process input on a touchscreen.
At the moment it is just a dpad (it currently lacks a,b,x,y like most standard gamepads have).
Basically you use paddy.dpad.isDown("left") instead of love.keyboard.isDown("left") in your love.update() function.
There's an example file here (dpad only works on touch enabled device).
paddy - touchscreen controls
-
- Prole
- Posts: 9
- Joined: Wed Aug 16, 2017 9:56 pm
Re: paddy - touchscreen controls
Just put your example file on my mobile, and it looks and feels great!
Also like the keyboard analogy in the paddy.dpad.isDown-stuff.
All in one very readable and not too complex lua file. (I'm just starting with LÖVE.) Nice!
Looking forward to your next steps with paddy.
Also like the keyboard analogy in the paddy.dpad.isDown-stuff.
All in one very readable and not too complex lua file. (I'm just starting with LÖVE.) Nice!
Looking forward to your next steps with paddy.
Re: paddy - touchscreen controls
Amazing! Feels great, Works great and Looks great. Thanks to help me to my game developing!
Hi! I wish you have an amazing day!
Re: paddy - touchscreen controls
For those who want to add missing A and B keys,
just alter 1 line of code:
It makes the d-pad canvas wider. You need it to see your new A&B buttons.
And add 2 items into paddy.dpad.buttons table:
If you want to see the buttons aliases on the screen, then add this line
before END of the 1st for loop.
-----
This is a nice and tidy lib. But there is another approach - to add touch controls to a popular input lib
as tactile.lua or so on/
just alter 1 line of code:
Code: Select all
paddy.dpad.canvas = love.graphics.newCanvas(paddy.dpad.w + 400 ,paddy.dpad.h)
And add 2 items into paddy.dpad.buttons table:
Code: Select all
{ name="a", x=paddy.buttonw*3, y=paddy.buttonh },
{ name="b", x=paddy.buttonw*4, y=paddy.buttonh },
Code: Select all
love.graphics.print(button.name, button.x+paddy.dpad.padding, button.y+paddy.dpad.padding )
-----
This is a nice and tidy lib. But there is another approach - to add touch controls to a popular input lib
as tactile.lua or so on/
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua
LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua
Re: paddy - touchscreen controls
Hey, thanks for suggesting that D0NM. I recently changed things a bit, not the best code. But it now supports two kinds of "widgets". One for the dpad, and one for a playstation/snes style button pad.
I also decided to change the paddy.dpad.isDown("left") to simply paddy.isDown("left"), so that this is shared for all buttons, eg;
paddy.isDown("a"). I might change it back yet when i can rewrite some parts of it.
I also decided to change the paddy.dpad.isDown("left") to simply paddy.isDown("left"), so that this is shared for all buttons, eg;
paddy.isDown("a"). I might change it back yet when i can rewrite some parts of it.
Who is online
Users browsing this forum: No registered users and 1 guest