Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- touchTest= function (event)
- local t = event.target
- local phase = event.phase
- if "began" == phase then
- print ("TOUCHED!")
- end
- print ("touch Test!")
- return true
- end
- onScreenSwipe = function( event )
- local t = event.target
- local phase = event.phase
- -- local howManyHits = event.numTaps
- local minmov = 12 -- Minimum movement that registers
- if "began" == phase then
- t.isFocus = true
- t.x0 = event.x
- t.y0 = event.y
- print ()
- print ("bookEvent.X:" .. event.x)
- print ("bookEvent.Y:" .. event.y)
- print ("phase = " .. phase )
- elseif ("ended" == phase or "cancelled" == phase) and t.x0 ~= nil and t.y0 ~= nil then
- -- print ("Number of taps: " .. event.numTaps)
- if (event.x - t.x0) > minmov then -- Swipe right
- display.getCurrentStage():setFocus( nil )
- t.isFocus = false
- -- io.write("\nSWIPE RIGHT!!!! <-----I====================>")
- if npcInFrontOf > 0 then
- Runtime:dispatchEvent{name='playerHasMoved'}
- if currentMap.monsterList[npcInFrontOf].npcPurpose == "fight" then
- swingSwordRight()
- else
- talkToNpc()
- end
- else
- Runtime:dispatchEvent{name='playerHasMoved'}
- swingSwordRight()
- end
- --haltPlayerInput()
- t.x0 = nil
- t.y0 = nil
- elseif (event.x - t.x0) < -minmov then -- Swipe Left
- display.getCurrentStage():setFocus( nil )
- t.isFocus = false
- --io.write ("\nSWIPE LEFT!!!! <-----I====================>")
- if npcInFrontOf > 0 then
- Runtime:dispatchEvent{name='playerHasMoved'}
- if currentMap.monsterList[npcInFrontOf].npcPurpose == "fight" then
- swingSwordLeft()
- else
- talkToNpc()
- end
- else
- Runtime:dispatchEvent{name='playerHasMoved'}
- swingSwordLeft()
- end
- t.x0 = nil
- t.y0 = nil
- else
- display.getCurrentStage():setFocus( nil )
- t.isFocus = false
- return false
- end
- display.getCurrentStage():setFocus( nil )
- t.isFocus = false
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement