Libraries.Vibration.VibrationArray Documentation

The VibrationArray class allows programmers to create custom vibration patterns for use with the Vibration class.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.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 array
                array:Add(2)
                array:Add(1, 0)
                vibrator:VibrateForever(array)
            end

        end

Inherits from: Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
Add(number seconds, number intensity)Adds a new item with the given duration and intensity to the VibrationArray.
Add(Libraries.Vibration.VibrationCommand item)Adds a VibrationCommand to the VibrationArray.
Add(number seconds)Adds a new item with the given duration to the VibrationArray.
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.
Get(integer index)Retrieves the VibrationCommand stored at the given index, which contains the duration in seconds and the intensity.
GetDuration(integer index)Retrieves the duration of the item stored at the given index.
GetHashCode()This action gets the hash code for an object.
GetIntensity(integer index)Retrieves the intensity of the item stored at the given index.
GetSize()Returns the number of items held within the VibrationArray.
Remove(integer index)Removes the item stored at the given index of the VibrationArray.
RemoveAll()Clears all items in the VibrationArray.

Actions Documentation

Add(number seconds, number intensity)

Adds a new item with the given duration and intensity to the VibrationArray. Duration is measured in seconds, and intensity is a number between 0.0 and 1.0.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.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 array

                array:Add(1, 0.5)

                vibrator:Vibrate(array)
            end

        end

Parameters

Add(Libraries.Vibration.VibrationCommand item)

Adds a VibrationCommand to the VibrationArray. The VibrationCommand contains a duration measured in seconds and an intensity, a number between 0.0 and 1.0.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.Vibration.VibrationArray
        use Libraries.Vibration.VibrationCommand
        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 array
                VibrationCommand command

                command:SetDuration(1)
                command:SetIntensity(0.5)

                array:Add(command)

                vibrator:Vibrate(array)
            end

        end

Parameters

Add(number seconds)

Adds a new item with the given duration to the VibrationArray. Duration is measured in seconds, and intensity defaults to 1.0, or maximum intensity.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.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 array

                array:Add(1)

                vibrator:Vibrate(array)
            end

        end

Parameters

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 (smaller)

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(t)

Parameters

Return

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

Get(integer index)

Retrieves the VibrationCommand stored at the given index, which contains the duration in seconds and the intensity.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.Vibration.VibrationArray
        use Libraries.Vibration.VibrationCommand
        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 array
                VibrationCommand command

                command:SetDuration(1)
                command:SetIntensity(0.5)

                array:Add(command)

                VibrationCommand newCommand
                newCommand = array:Get(0)

                array:Add(newCommand)

                vibrator:Vibrate(array)
            end

        end

Parameters

Return

Libraries.Vibration.VibrationCommand: The item, a VibrationCommand containing both a duration in seconds and an intensity between 0.0 and 1.0, at the given index.

GetDuration(integer index)

Retrieves the duration of the item stored at the given index. This returned duration is measured in seconds.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.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 array

                array:Add(1)

                number newDuration = array:GetDuration(0)
                array:Add(newDuration)

                vibrator:Vibrate(array)
            end

        end

Parameters

Return

number: The duration, measured in seconds, of the item at the given index.

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.

GetIntensity(integer index)

Retrieves the intensity of the item stored at the given index. This returned intensity is a number between 0.0 and 1.0.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.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 array

                array:Add(1, 0.5)

                number newDuration = array:GetDuration(0)
                number newIntensity = array:GetIntensity(0)
                array:Add(newDuration, newIntensity)

                vibrator:Vibrate(array)
            end

        end

Parameters

Return

number: The intensity, a number between 0.0 and 1.0, of the item at the given index.

GetSize()

Returns the number of items held within the VibrationArray.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.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 array

                array:Add(1, 0.5)
                array:Add(2, 1)

                output array:GetSize()

                vibrator:Vibrate(array)
            end

        end

Return

integer: The amount of items stored within the VibrationArray.

Remove(integer index)

Removes the item stored at the given index of the VibrationArray.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.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 array

                array:Add(1, 0.5)
                array:Add(2, 1)

                array:Remove(0)

                vibrator:Vibrate(array)
            end

        end

Parameters

RemoveAll()

Clears all items in the VibrationArray.

Example Code

use Libraries.Vibration.Vibration
        use Libraries.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 array

                array:Add(1, 0.5)
                array:Add(2, 1)
                array:Add(0.5, 0.75)
                array:Add(1)

                array:RemoveAll()

                array:Add(1)

                vibrator:Vibrate(array)
            end

        end