Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --]]
- --
- -- />
- -- ( //------------------------------------------------------(
- -- (*)OXOXOXOXO(*>----------------- ATTACK !!! \
- -- ( \\--------------------------------------------------------)
- -- \>
- --
- --
- --
- --
- onScreenSwipe = function( event )
- local t = event.target
- local phase = event.phase
- local minmov = 60 -- Minimum movement that registers
- if "began" == phase then
- t.isFocus = true
- t.x0 = event.x
- t.y0 = event.y
- elseif ("ended" == phase or "cancelled" == phase) and t.x0 ~= nil and t.y0 ~= nil then
- if (event.x - t.x0) > minmov then -- Swipe right
- --io.write("\nSWIPE RIGHT!!!!")
- swingSwordRight()
- Runtime:dispatchEvent{name='playerHasMoved'}
- elseif (event.x - t.x0) < -minmov then -- Swipe Left
- --io.write ("\nSWIPE LEFT!!!!")
- swingSwordLeft()
- Runtime:dispatchEvent{name='playerHasMoved'}
- else
- raiseLowerShield()
- Runtime:dispatchEvent{name='playerHasMoved'}
- end
- display.getCurrentStage():setFocus( nil )
- t.isFocus = false
- --Runtime:dispatchEvent{name='playerHasFinished'} -- This will send it on a nasty infinite loop...
- end
- return true
- end
- ui_layout.elements.TouchArea:addEventListener( 'touch', onScreenSwipe )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement