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]
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]
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.
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]
[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]
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.
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]
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]