Libraries.Interface.Vibration.Vibration Documentation

The Vibration class can be used to start vibration patterns on devices with a vibration motor.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:VibrateForever()
            end
        e

Inherits from: Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetHashCode()This action gets the hash code for an object.
Knock(integer repetitions)This method vibrates according to a preset pattern, which has two quick vibrations followed by a long pause and a final vibration.
KnockForever()This method vibrates according to a preset pattern, which has two quick vibrations followed by a long pause and a final vibration.
KnockOnce()This method vibrates according to a preset pattern, which has two quick vibrations followed by a long pause and a final vibration.
QuickPulse(number seconds)This method vibrates according to a preset pattern, which has quick vibrations in rapid succession, repeating for the specified number of seconds.
QuickPulseForever()This method vibrates according to a preset pattern, which has quick vibrations with short pauses in between, repeating until the Stop() action is called.
Rumble(number seconds)This method vibrates according to a preset pattern, creating a low-intensity vibration with very short pauses, repeating for the specified number of seconds.
RumbleForever()This method vibrates according to a preset pattern, creating a low-intensity vibration with very short pauses, repeating until the Stop() action is called.
SlowPulse(number seconds)This method vibrates according to a preset pattern, which has slow vibrations with relatively long pauses in between, repeating for the specified number of seconds.
SlowPulseForever()This method vibrates according to a preset pattern, which has slow vibrations with relatively long pauses in between, repeating until the Stop() action is called.
Stop()Cancels the current vibration.
Vibrate(number seconds)This method turns on the motor, vibrating constantly at maximum intensity for the number of seconds specified.
Vibrate(number seconds, number intensity)This method turns on the motor, vibrating constantly for the number of seconds specified at the given intensity.
Vibrate(Libraries.Interface.Vibration.VibrationArray vibrationArray, integer repetitions)This method plays a vibration pattern created with a VibrationArray.
VibrateAtFrequency(number seconds, number frequency)Plays a vibration at the given frequency for the given number of seconds.
VibrateAtFrequencyForever(number frequency)Plays a vibration at the given frequency, repeating until the Stop() action is called.
VibrateForever(Libraries.Interface.Vibration.VibrationArray vibrationArray)This method plays a vibration pattern created with a VibrationArray, repeating until the Stop() action is called.
VibrateForever()This method turns on the motor, vibrating constantly at maximum intensity, repeating until the Stop() action is called.
VibrateForever(number intensity)This method turns on the motor, vibrating constantly at the given intensity, repeating until the Stop() action is called.
VibrateOnce(Libraries.Interface.Vibration.VibrationArray vibrationArray)This method plays a vibration pattern created with a VibrationArray.

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.

Example Code

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

Parameters

Return

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

Equals(Libraries.Language.Object object)

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

Example Code

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

Parameters

Return

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

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode

Return

integer: The integer hash code of the object.

Knock(integer repetitions)

This method vibrates according to a preset pattern, which has two quick vibrations followed by a long pause and a final vibration. Repeats the pattern for the amount of times specified.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:Knock(3)
            end
        e

Parameters

KnockForever()

This method vibrates according to a preset pattern, which has two quick vibrations followed by a long pause and a final vibration. Repeats the pattern until the Stop() action is called.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:KnockForever()
            end
        e

KnockOnce()

This method vibrates according to a preset pattern, which has two quick vibrations followed by a long pause and a final vibration.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:KnockOnce()
            end
        e

QuickPulse(number seconds)

This method vibrates according to a preset pattern, which has quick vibrations in rapid succession, repeating for the specified number of seconds.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:QuickPulse(2.5)
            end
        e

Parameters

QuickPulseForever()

This method vibrates according to a preset pattern, which has quick vibrations with short pauses in between, repeating until the Stop() action is called.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:QuickPulseForever()
            end
        e

Rumble(number seconds)

This method vibrates according to a preset pattern, creating a low-intensity vibration with very short pauses, repeating for the specified number of seconds.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:Rumble(2.5)
            end
        e

Parameters

RumbleForever()

This method vibrates according to a preset pattern, creating a low-intensity vibration with very short pauses, repeating until the Stop() action is called.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:RumbleForever()
            end
        e

SlowPulse(number seconds)

This method vibrates according to a preset pattern, which has slow vibrations with relatively long pauses in between, repeating for the specified number of seconds.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:SlowPulse(2.5)
            end
        e

Parameters

SlowPulseForever()

This method vibrates according to a preset pattern, which has slow vibrations with relatively long pauses in between, repeating until the Stop() action is called.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:SlowPulseForever()
            end
        e

Stop()

Cancels the current vibration.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action ContinuedTouch(TouchEvent event)
                if (event:GetX() >= 200 and event:GetX() <= 300) and (event:GetY() >= 900 and event:GetY() <= 1600)
                    vibrator:VibrateAtFrequency(10)
                elseif (event:GetX() >= 200 and event:GetX() <= 300) and (event:GetY() >= 200 and event:GetY() <= 900)
                    vibrator:VibrateAtFrequency(2.5)
                else
                    vibrator:Stop()
                end
            end
        e

Vibrate(number seconds)

This method turns on the motor, vibrating constantly at maximum intensity for the number of seconds specified.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:Vibrate(2.5)
            end
        e

Parameters

Vibrate(number seconds, number intensity)

This method turns on the motor, vibrating constantly for the number of seconds specified at the given intensity. The intensity is expected to be a number between 0.0 and 1.0, representing a percentage of the maximum intensity allowed by the device.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:Vibrate(2.5, 0.5)
            end
        e

Parameters

Vibrate(Libraries.Interface.Vibration.VibrationArray vibrationArray, integer repetitions)

This method plays a vibration pattern created with a VibrationArray. Repeats the pattern for the amount of times specified.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Interface.Vibration.VibrationArray
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                VibrationArray pattern

                patter:Add(1.5, 0.5)
                pattern:Add(0.5, 0.0)
                pattern:Add(1)

                vibrator:Vibrate(pattern, 5)
            end
        e

Parameters

VibrateAtFrequency(number seconds, number frequency)

Plays a vibration at the given frequency for the given number of seconds. The frequency is measured in Hertz (Hz).

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:VibrateAtFrequency(2, 2.5)
            end
        e

Parameters

VibrateAtFrequencyForever(number frequency)

Plays a vibration at the given frequency, repeating until the Stop() action is called. The frequency is measured in Hertz (Hz).

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:VibrateAtFrequencyForever(2.5)
            end
        e

Parameters

VibrateForever(Libraries.Interface.Vibration.VibrationArray vibrationArray)

This method plays a vibration pattern created with a VibrationArray, repeating until the Stop() action is called.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Interface.Vibration.VibrationArray
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                VibrationArray pattern

                patter:Add(1.5, 0.5)
                pattern:Add(0.5, 0.0)
                pattern:Add(1)

                vibrator:VibrateForever(pattern)
            end
        e

Parameters

VibrateForever()

This method turns on the motor, vibrating constantly at maximum intensity, repeating until the Stop() action is called.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:VibrateForever()
            end
        e

VibrateForever(number intensity)

This method turns on the motor, vibrating constantly at the given intensity, repeating until the Stop() action is called. The intensity is expected to be a number between 0.0 and 1.0, representing a percentage of the maximum intensity allowed by the device.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                vibrator:VibrateForever(0.5)
            end
        e

Parameters

VibrateOnce(Libraries.Interface.Vibration.VibrationArray vibrationArray)

This method plays a vibration pattern created with a VibrationArray.

Example Code

use Libraries.Interface.Vibration.Vibration
        use Libraries.Interface.Vibration.VibrationArray
        use Libraries.Game.Game
        use Libraries.Interface.Events.TouchListener
        use Libraries.Interface.Events.TouchEvent

        class Main is Game, TouchListener

            Vibration vibrator

            action Main
                StartGame()
            end

            action CreateGame
                AddTouchListener(me)
            end

            action BeganTouch(TouchEvent event)
                VibrationArray pattern

                patter:Add(1.5, 0.5)
                pattern:Add(0.5, 0.0)
                pattern:Add(1)

                vibrator:VibrateOnce(pattern)
            end
        e

Parameters