This site requires JavaScript, please enable it in your browser!
Greenfoot back
Higgins1904
Higgins1904 wrote ...

2019/11/14

Code for swiping and tapping at touch screen

Higgins1904 Higgins1904

2019/11/14

#
Hi, new to Greenfoot I have started tpo evaluate if I can use it for my Project. So far so good, but I need support for running it with a touch screen so I need to code for user input by swiping and tapping. Can that that be done? Will the code use functionality for mouse events when user taps or swipes? Thanks and regards, Higgins
nccb nccb

2019/11/14

#
Greenfoot can run on your local machine or on the website which lets it run on phone, tablet, etc. It doesn't directly support touch events on any of these platforms, but usually touch events will be translated into mouse events -- although they may be translated slightly differently by different devices. Tapping is almost certainly rendered into a click. I don't for sure about swiping, but I suspect it will show up as a mouse-drag, although you may then have to perform the calculations to decide which direction the swipe is in, how long it lasts, etc.
danpost danpost

2019/11/14

#
nccb wrote...
I suspect it will show up as a mouse-drag, although you may then have to perform the calculations to decide which direction the swipe is in, how long it lasts, etc.
Your suspicion was correct. Mouse dragging can be translated into swiping using direction and speed of dragging.
danpost danpost

2019/11/14

#
I have published a sample demo with source for anyone interested -- Tap and Swipe Demo. Will document and re-upload shortly.
Higgins1904 Higgins1904

2019/11/14

#
My plan is to run my program at a Raspberry Pi 4 with a 7" or 10 " touch screen, so it will in effect by quite similar to a pad. Will dive into your demo now!
You need to login to post a reply.