Libraries.Interface.Events.GestureListener Documentation

The GestureListener class is used to react to gestures on mobile platforms (iOS and Android).

Example Code

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnSingleTap(GestureEvent event)
    Log("Single tap!")
end

action OnDoubleTap(GestureEvent event)
    Log("Double tap!")
end

action OnSwipe(GestureEvent event)
    Log("Swipe!")
end

action OnPan(GestureEvent event)
    Log("Pan!")
end

action OnLongPressBegin(GestureEvent event)
    Log("Long press started!")
end

action OnLongPressEnd(GestureEvent event)
    Log("Long press finished!")
end

action OnPinchBegin(GestureEvent event)
    Log("Begin pinch!")
end

action OnPinchContinue(GestureEvent event)
    Log("Continue pinch!")
end

action OnPinchEnd(GestureEvent event)
    Log("End pinch!")
end
end

Inherits from: Libraries.Language.Object

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

OnDoubleTap(Libraries.Interface.Events.GestureEvent event)

The OnDoubleTap action is triggered when the user taps the screen twice in rapid succession.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnDoubleTap(GestureEvent event)
    Log("Double tap!")
end
end

OnLongPressBegin(Libraries.Interface.Events.GestureEvent event)

The OnLongPressBegin action is triggered when the user places a finger on the screen and holds it still for a short time.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnLongPressBegin(GestureEvent event)
    Log("Long press started!")
end
end

OnLongPressEnd(Libraries.Interface.Events.GestureEvent event)

The OnLongPressEnd action is triggered when the user lifts a finger off the screen that had started a long press.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnLongPressEnd(GestureEvent event)
    Log("Long press finished!")
end
end

OnPan(Libraries.Interface.Events.GestureEvent event)

The OnPan action is triggered when the user places a finger on the screen and drags it in a direction. Pan gestures can be triggered by fast or slow movement, and the action will be triggered on each frame of animation where the finger moves.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnPan(GestureEvent event)
    Log("Pan! The distance moved was " + event:GetPanDistanceX() + ", " + event:GetPanDistanceY())
end
end

OnPinchBegin(Libraries.Interface.Events.GestureEvent event)

The OnPinchBegin action is triggered when the user starts a pinching gesture (when a user places two fingers on the screen and moves them closer or farther apart). This gesture is commonly used for zooming.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnPinchBegin(GestureEvent event)
    Log("Begin pinch!")
end

action OnPinchContinue(GestureEvent event)
    Log("Continue pinch!")
end

action OnPinchEnd(GestureEvent event)
    Log("End pinch!")
end
end

OnPinchContinue(Libraries.Interface.Events.GestureEvent event)

The OnPinchContinue action is triggered on each frame of animation when a user moves their fingers during a pinching gesture (when a user places two fingers on the screen and moves them closer or farther apart). This gesture is commonly used for zooming.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnPinchBegin(GestureEvent event)
    Log("Begin pinch!")
end

action OnPinchContinue(GestureEvent event)
    Log("Continue pinch!")
end

action OnPinchEnd(GestureEvent event)
    Log("End pinch!")
end
end

OnPinchEnd(Libraries.Interface.Events.GestureEvent event)

The OnPinchEnd action is triggered when the user completes a pinching gesture (when a user places two fingers on the screen and moves them closer or farther apart). This gesture is commonly used for zooming.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnPinchBegin(GestureEvent event)
    Log("Begin pinch!")
end

action OnPinchContinue(GestureEvent event)
    Log("Continue pinch!")
end

action OnPinchEnd(GestureEvent event)
    Log("End pinch!")
end
end

OnSingleTap(Libraries.Interface.Events.GestureEvent event)

The OnSingleTap action is triggered when the user taps a single time on an element. This action won't trigger if the user taps multiple times in rapid succession (for example, if the user is performing a double tap, this action won't trigger).

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnSingleTap(GestureEvent event)
    Log("Single tap!")
end
end

OnSwipe(Libraries.Interface.Events.GestureEvent event)

The OnSwipe action is triggered when the user places a finger on the screen and quickly drags it in a direction. The swipe gesture only tracks the direction of the swipe in the cardinal directions (right, left, up, and down). Swipes occur in conjunction with pan gestures, which contain more specific information regarding finger movement.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidApplication
use Libraries.Game.IOSApplication
use Libraries.Interface.Events.GestureListener
use Libraries.Interface.Events.GestureEvent
use Libraries.Game.GameStateManager

class Main is Game, GestureListener

action Main
    StartGame()
end

action CreateGame
    AddGestureListener(me)
end

// This action will output a value to the Android or iOS device logs,
// or output to the console if it's on a different platform.
action Log(text value)
    GameStateManager manager
    if manager:GetApplication() is IOSApplication
        IOSApplication app = cast(IOSApplication, manager:GetApplication())
        app:Log(value)
    elseif manager:GetApplication() is AndroidApplication
        AndroidApplication app = cast(AndroidApplication, manager:GetApplication())
        app:Log(value)
    else
        output value
    end
end

action OnSwipe(GestureEvent event)
    Log("Swipe! The direction code was " + event:GetDirection())
end
end