Libraries.Interface.Vibration.VibrationArray Documentation
The VibrationArray class allows programmers to create custom vibration patterns for use with the Vibration class.
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 array
array:Add(2)
array:Add(1, 0)
vibrator:VibrateForever(array)
end
end
Inherits from: Libraries.Language.Object
Actions Documentation
Add(Libraries.Interface.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.
Parameters
- Libraries.Interface.Vibration.VibrationCommand: One segment of a pattern, with a duration in seconds and an intensity between 0.0 and 1.0, stored within a VibrationCommand object.
Example
use Libraries.Interface.Vibration.Vibration
use Libraries.Interface.Vibration.VibrationArray
use Libraries.Interface.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
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.
Parameters
- number seconds: The number of seconds for the new item to vibrate for.
- number intensity: The intensity of the new item, given by a number between 0.0 and 1.0, which represents the percentage of maximum intensity at which to play.
Example
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 array
array:Add(1, 0.5)
vibrator:Vibrate(array)
end
end
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.
Parameters
- number seconds: The number of seconds for the new item to vibrate for.
Example
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 array
array:Add(1)
vibrator:Vibrate(array)
end
end
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
- Libraries.Language.Object: The object to compare to.
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
- Libraries.Language.Object: The to be compared.
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)
Get(integer index)
Retrieves the VibrationCommand stored at the given index, which contains the duration in seconds and the intensity.
Parameters
- integer index: The index or location the item is located at.
Return
Libraries.Interface.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.
Example
use Libraries.Interface.Vibration.Vibration
use Libraries.Interface.Vibration.VibrationArray
use Libraries.Interface.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
GetDuration(integer index)
Retrieves the duration of the item stored at the given index. This returned duration is measured in seconds.
Parameters
- integer index: The index or location the item is located at.
Return
number: The duration, measured in seconds, of the item at the given index.
Example
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 array
array:Add(1)
number newDuration = array:GetDuration(0)
array:Add(newDuration)
vibrator:Vibrate(array)
end
end
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()
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.
Parameters
- integer index: The index or location the item is located at.
Return
number: The intensity, a number between 0.0 and 1.0, of the item at the given index.
Example
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 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
GetSize()
Returns the number of items held within the VibrationArray.
Return
integer: The amount of items stored within the VibrationArray.
Example
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 array
array:Add(1, 0.5)
array:Add(2, 1)
output array:GetSize()
vibrator:Vibrate(array)
end
end
Remove(integer index)
Removes the item stored at the given index of the VibrationArray.
Parameters
- integer index: The index or location the item is located at.
Example
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 array
array:Add(1, 0.5)
array:Add(2, 1)
array:Remove(0)
vibrator:Vibrate(array)
end
end
RemoveAll()
Clears all items in the VibrationArray.
Example
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 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
On this page
Variables TableAction Documentation- Add(Libraries.Interface.Vibration.VibrationCommand item)
- Add(number seconds, number intensity)
- Add(number seconds)
- Compare(Libraries.Language.Object object)
- Equals(Libraries.Language.Object object)
- Get(integer index)
- GetDuration(integer index)
- GetHashCode()
- GetIntensity(integer index)
- GetSize()
- Remove(integer index)
- RemoveAll()