Hello everybody! I’m a new corona user and also new to code as well. I’ve been trying to work on a personal project that is supposed to be a tap music game.
Right now, I’m having trouble with figuring out how to have a tap event listener trigger on a different phase of the sprite. The idea is that the sprite will animate and play 5 frames, and depending on which frame the sprite is tapped on, it will give a different score.
I’ve browsed through the forums as well as googled, although I haven’t come up with a way to do this yet. I may simply just be looking for the wrong thing though. Here is my code that I set up for tapping and score and the actual object itself.
local function randomTap( event ) local function scoreUp( event ) score = score + 100 display.remove( timedTap ) timedTap = event.target if ( event.phase == "began" ) then score = score - 100 elseif ( event.phase == "next" ) then score = score - 60 elseif ( event.phase == "next" ) then score = score - 40 elseif ( event.phase == "next" ) then score = score - 20 elseif ( event.phase == "ended" ) then score = score + 0 end scoreText.text = "Score: " .. score end gameLoopTimer = timer.performWithDelay( 1000, display.remove( timedTap ), 1 ) timedTap = display.newSprite( sheetTap, sequencesTap ) timedTap.x = math.random( 25, 200 ) timedTap.y = math.random( 25, 400 ) timedTap:play() timedTap:addEventListener( "tap", scoreUp ) end