What are all the touch UI choices? Like tap,touch, etc.?

Hey all, what are the choices of input type? Is there a “double tap”? “Pinch”? etc.?
localGroup:addEventListener( “touch”, moveCamera )
localGroup:addEventListener( “tap”, worldTouchPoint )
Where are these covered in the docs, like the “touch” and “tap” above?

Appreciate any info!

Best,
Mario [import]uid: 11636 topic_id: 4707 reply_id: 304707[/import]

Yeah, is there a Fruit Ninja-like “swipe” or do you just record touch begin and end and that’s your swipe?

Jay
[import]uid: 9440 topic_id: 4707 reply_id: 14962[/import]

For a swipe
just record touch begin and end and that’s your swipe

The math for a pinch gesture is not particularly complicated. Basically just use good ole “A squared plus B squared equals C squared” to find the distance between the two touches, and if that gets smaller when the touches move then the user is pinching. [import]uid: 12108 topic_id: 4707 reply_id: 14979[/import]

Appreciate the help guys!

But, per my original question…Is there only “tap” and “touch”? :slight_smile: [import]uid: 11636 topic_id: 4707 reply_id: 15007[/import]

I found this thread while learning about the differences of TAP and TOUCH. I didn’t see if there were more options. It seems that just the two is limiting.

Here’s my example…

[lua]–> Clicky Button

click6 = audio.loadSound(“click-6.wav”)

local button = display.newCircle(display.contentWidth / 2, display.contentHeight / 2, 50)
button:setFillColor(150,200,255)

function button:tap(event)
audio.play(click6)
end

button:addEventListener(“tap”, button)[/lua]

I’m making a new “Free .WAV Wednesday” article at my site. For this week’s tutorial, I thought I’d write about Corona. But unfortunately, I’m not too happy with the way things turned out.

Basically, the tutorial is making a button that plays a sound when clicked. I figure if I’m going to sell sound files for game development, it helps to show how to use the files.

In the example, I can get the sound to play, but it doesn’t work perfectly. When “Tap” is selected, the click sound is played when the touch is released. When “Touch” is selected, the sound is played when the touch is pressed, released or moved within the circle.

Maybe it’s my limited understanding of Corona, but something doesn’t seem right. Considering that the question raised by mroberti was left unanswered, I think it might be a limitation of Corona. [import]uid: 13264 topic_id: 4707 reply_id: 25796[/import]

Try making your listener look like this:

function button:tap(event)  
 if event.phase == "began" then  
 audio.play(click6)  
 end  
end  

See if that makes a difference.

Jay
[import]uid: 9440 topic_id: 4707 reply_id: 25804[/import]

Okay, what I wrote didn’t work. :slight_smile:

But changing the last part of the code to this makes it work:

  
function buttontap(event)  
 if event.phase == "began" then  
 audio.play(click6)  
 end  
end  
   
button:addEventListener("touch", buttontap)  
  

Jay
[import]uid: 9440 topic_id: 4707 reply_id: 25808[/import]

Hey Jay, that code works.

This is what I’m using for the article though…

[lua]function button:touch(event)
if event.phase == “began”
then audio.play(click6)
end
end

button:addEventListener(“touch”, button)[/lua]

So basically, it’s like two detections going on… first detecting the touch, then detecting the start of the touch. That seems a bit redundant. Perhaps there should be another alternative to Touch and Tap.

One of the big things that frustrated me was that I couldn’t simplify it. I didn’t even want the circle…

if screen is touched, play sound

…but I couldn’t figure out how to do that. I’m still figuring out events and listeners. [import]uid: 13264 topic_id: 4707 reply_id: 25815[/import]

If you don’t want the button, try this:

click6 = audio.loadSound("something.wav")  
   
function beentapped(event)  
 if event.phase == "began" then  
 audio.play(click6)  
 end  
end  
   
Runtime:addEventListener("touch", beentapped)  

A click anywhere on the screen will play the sound.

jay
[import]uid: 9440 topic_id: 4707 reply_id: 25826[/import]

Okay, because I can’t leave well enough along, here’s my new version:

  
local isPlaying = false  
local audioFile = "gentle-idle.mp3"  
  
local click6 = audio.loadSound(audioFile)  
   
function beentapped(event)  
 if event.phase == "began" then  
 if isPlaying then  
 audio.stop ( )  
 else  
 audio.play(click6)  
 end  
 isPlaying = not isPlaying  
 end  
end  
   
Runtime:addEventListener("touch", beentapped)  

Two changes – first, the audio file is put into a variable just so it’s in one spot but can be used in many spots (more easily). So if you wanted to print to the screen which sound was playing, now you can do that – and only make a change in one spot for each new sound.

Second, I added the isPlaying var so if you have long sounds you can tap the screen to turn it off. Tap on, tap off.

Use it or not, it’s there. :slight_smile:

Jay

PS - That isPlaying = not isPlaying line in there is just a sneaky way to toggle a boolean value from true to false or false to true.
[import]uid: 9440 topic_id: 4707 reply_id: 25828[/import]

Heh, maybe you should write this book.

I decided to keep my version of the code.

The tutorial is here…
http://photics.com/free-wav-wednesday-click-6

Since it uses the word “Wednesday” in the title, the article is hidden until 12PM Eastern.

I think your examples are cool. The first one I thought I tried already, but I wasn’t able to get it to work. I was like, “Why isn’t this working?” Heh, I must have messed something up.

I’m still getting used to the whole event listener thing. [import]uid: 13264 topic_id: 4707 reply_id: 25832[/import]

don’t forget “touch” also has the “moved” phase [import]uid: 6645 topic_id: 4707 reply_id: 25848[/import]