Libraries.Game.Audio3D Documentation

Inherits from: Libraries.Interface.Item3D, Libraries.Interface.Item, Libraries.Language.Object, Libraries.Sound.Audio

Actions Documentation

Add(Libraries.Interface.Item3D newItem)

This action adds a different Item3D into this one. This makes a few things happen. 1. The added item will get this item as its parent. 2. The added item's x, y, and z coordinates will become relative to this Item. 3. Most actions on this Item will also affect the added Item.

Parameters

Example

use Libraries.Interface.Item3D

Item3D parentItem
Item3D child
parentItem:Add(child)

Add(integer index, Libraries.Interface.Item3D newItem)

This action adds a different Item3D into this one, storing the added Item3D at a specific index in the internal array.

Parameters

Example

use Libraries.Interface.Item3D

Item3D parentItem
Item3D child
parentItem:Add(0, child)

AddBehavior(Libraries.Interface.Behaviors.Behavior behavior)

This action adds a new Behavior to this Item.

Parameters

AddFocusListener(Libraries.Interface.Events.FocusListener listener)

This action adds a FocusListener to the Item. When the Item receives a FocusEvent due to either gaining or losing the focus, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.FocusListener
Item myItem
FocusListener listener
myItem:AddFocusListener(listener)

AddGestureListener(Libraries.Interface.Events.GestureListener listener)

This action adds a GestureListener to the Item. If the Item ever receives a GestureEvent, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.GestureListener
Item myItem
GestureListener listener
myItem:AddGestureListener(listener)

AddMouseListener(Libraries.Interface.Events.MouseListener listener)

This action adds a MouseListener to the Item. If the Item ever receives a MouseEvent due to a mouse click, the mouse listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseListener
Item myItem
MouseListener listener
myItem:AddMouseListener(listener)

AddMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)

This action adds a MouseMovementListener to the Item. If the Item ever receives a MouseEvent due to mouse movement, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseMovementListener
Item myItem
MouseMovementListener listener
myItem:AddMouseMovementListener(listener)

AddMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)

This action adds a MouseWheelListener to the Item. If the Item ever receives a MouseEvent due to the mouse wheel being scrolled, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseWheelListener
Item myItem
MouseWheelListener listener
myItem:AddMouseWheelListener(listener)

AddToQueue(Libraries.Sound.AudioSamples samples)

The AddToQueue action adds AudioSamples to the end of the data stored in this Audio object. To use this, the Audio must have been initialized using LoadToStream using an AudioSamples object, or must not have been initialized yet. This action can't be combined with actions that load a file into the Audio.

Parameters

Example



use Libraries.Sound.AudioSamples
use Libraries.Sound.Audio

Audio audio

AudioSamples samples1
AudioSamples samples2
AudioSamples samples3

samples1:Load("Sonata-Part1.ogg")
samples2:Load("Sonata-Part2.ogg")
samples3:Load("Sonata-Part3.ogg")

audio:LoadToStream(samples1)
audio:AddToQueue(samples2)
audio:AddToQueue(samples3)

audio:Play()
repeat while audio:IsPlaying()
    audio:Stream()
end

AddTouchListener(Libraries.Interface.Events.TouchListener listener)

This action adds a TouchListener to the Item. If the Item ever receives a TouchEvent, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.TouchListener
Item myItem
TouchListener listener
myItem:AddTouchListener(listener)

ApplyAngularImpulse(Libraries.Compute.Vector3 impulse)

This action will increase the y-coordinate of this Item by the given amount.

Parameters

Example

use Libraries.Interface.Item3D

Item3D myItem
myItem:SetY(50)
myItem:MoveY(25)

ApplyDamping(number seconds)

Parameters

  • number seconds

ApplyForce(Libraries.Compute.Vector3 force, Libraries.Compute.Vector3 point)

transform:Translate(xAmount, yAmount, -zAmount)

Parameters

ApplyForceToCenter(Libraries.Compute.Vector3 force)

This action will increase the x, y, and z coordinates of this Item by the given amounts.

Parameters

Example

use Libraries.Interface.Item3D

Item3D myItem
myItem:SetPosition(50, 25, 80)
myItem:Move(25, 15, -20)

ApplyImpulse(Libraries.Compute.Vector3 impulse, Libraries.Compute.Vector3 localPositionToApply)

ACTIONS MADE FOR JOINTS.

Parameters

ApplyLinearImpulse(Libraries.Compute.Vector3 impulse, Libraries.Compute.Vector3 point)

This action will increase the z-coordinate of this Item by the given amount.

Parameters

Example

use Libraries.Interface.Item3D

Item3D myItem
myItem:SetZ(50)
myItem:MoveZ(25)

ApplyLinearImpulseToCenter(Libraries.Compute.Vector3 impulse)

ACTIONS MADE FOR JOINTS.

Parameters

ApplyTorque(Libraries.Compute.Vector3 torque)

transform:Translate(0, 0, -zAmount)

Parameters

ApplyTorqueImpulse(Libraries.Compute.Vector3 torque)

BeginCollision(Libraries.Interface.Item item)

This action is used to indicate that two items have just begun colliding. When two Items collide, the BeginCollision action should be called on both of them, with the other item passed as a parameter to the action. Note that this action does nothing by default, but classes that inherit from Item may override it.

Parameters

Example

use Libraries.Interface.Item

Item collider1
Item collider2
collider1:BeginCollision(collider2)
collider2:BeginCollision(collider1)

CanRotate(boolean flag)

Parameters

  • boolean flag

CancelBehaviors()

This action stops all behaviors this Item is following without finishing them.

CollideWithChildren()

Return

boolean

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)

ComputeAngularImpulseDenominator(Libraries.Compute.Vector3 axis)

Parameters

Return

number

ComputeImpulseDenominator(Libraries.Compute.Vector3 position, Libraries.Compute.Vector3 normal)

CreateNodes(Libraries.Game.Collision.BroadphaseCollision3D broadphase, Libraries.Game.Collision.PhysicsPosition3D transform)

This action will take a TouchEvent and distribute it to any TouchListeners that have been added to this Item3D. This action will also set the event to the "handled" state.

Parameters

Example

use Libraries.Interface.Item2D
use Libraries.Interface.Events.TouchEvent
use Libraries.Interface.Events.TouchListener
Item2D myItem
TouchListener listener
myItem:AddTouchListener(listener)
TouchEvent event
event:eventType = event:BEGAN
myItem:ProcessTouchEvent(event)

DestroyNodes(Libraries.Game.Collision.BroadphaseCollision3D broadphase)

This action will remove all Items from this Item's children hierarchy. Note that this will not empty the hierarchies of the contained Items.

Parameters

Example

use Libraries.Interface.Item3D

Item3D parentItem
Item3D child1
Item3D child2
Item3D grandchild
parentItem:Add(child1)
parentItem:Add(child2)
child1:Add(grandChild)
parentItem:Empty()

DisableDoppler()

DisableDoppler will stop the audio from automatically calculating doppler shift.

Example



use Libraries.Sound.Audio

Audio audio
audio:Load("Sound.wav")

// The doppler effect is only noticable if the audio has velocity.
audio:SetVelocity(4, 0, -2)

// Because we disable the doppler effect here, the velocity we just set will
// have no effect.
audio:DisableDoppler()

DisableListenerDoppler()

DisableListenerDoppler will make the audio engine stop using the velocity of the listener when calculating doppler effect. This will NOT stop the engine from using the velocity of other audio objects that do have doppler enabled when calculating the doppler shift. The listener is universal to all audio objects, so disabling doppler effect on the listener will be in effect during calculation of doppler shift for ALL audio objects.

Example



use Libraries.Sound.Audio

Audio audio
audio:Load("Whale.wav")

// In order to hear the doppler effect in action, the listener needs
// to have velocity.
audio:SetListenerVelocity(5, 0, 4)

// Because we are now disabling the doppler effect on the listener, the
// velocity we gave it will have no effect.
audio:DisableListenerDoppler()

DisableLooping()

DisableLooping will ensure that an audio file stops playing when it reaches the end of the sound, instead of repeating. This is the default behavior, so it is only necessary to call this if there was a call to EnableLooping earlier in the program.

Example



use Libraries.Sound.Audio

// To use audio, we'll first need to create an object for it.
Audio audio

// We need to load our audio before we change whether or not it will loop.
audio:Load("test.wav")

// We now enable looping. This will make the sound repeat forever until we
// stop it or call "audio:DisableLooping()".
audio:EnableLooping()

// Our audio is currently set to loop. We can disable it again using DisableLooping().
audio:DisableLooping()

Dispose()

This action is used to free up any additional memory that is being used by this Item for purposes such as graphics. Note that the Item class doesn't have any extra memory that needs to be released with this action, but some classes which inherit from Item, such as Libraries.Game.Graphics.Drawable, do.

DisposeAll()

This action is used to call Dispose on this Item and on the entire children hierarchy of this Item.

DisposeChildren()

This action is used to call Dispose on the entire children hierarchy of this Item. This will not call Dispose on this Item.

Draw(Libraries.Game.Graphics.Painter3D painter)

This action is used to draw this Item on the screen, and then draw all of the Item's children hierarchy on the screen. Note that Items themselves can not be drawn, but some classes that extend the Item class, such as the Libraries.Game.Graphics.Model class, can be. To see how they draw, see their documentation.

Parameters

Empty()

This action will remove all Items from this Item's children hierarchy. Note that this will not empty the hierarchies of the contained Items.

Example

use Libraries.Interface.Item3D

Item3D parentItem
Item3D child1
Item3D child2
Item3D grandchild
parentItem:Add(child1)
parentItem:Add(child2)
child1:Add(grandChild)
parentItem:Empty()

EmptyAll()

This action will call Empty on the entire children hierarchy of this item, and then empty this item as well.

EmptyChildren()

This action is used to call Empty on all children contained in this item's children hierarchy. This will not empty the children of this item.

EnableDoppler()

EnableDoppler will make the audio automatically calculate doppler shift for this audio. Doppler is enabled by default for audio, but will have no effect until the user provides the velocity of the audio via an action, such as SetVelocity(Vector3).

Example



use Libraries.Sound.Audio

Audio audio
audio:Load("Sound.wav")

// We need to set the velocity of the audio in order to hear the doppler effect.
audio:SetVelocity(4, 0, -2)

// Doppler is already enabled by default, so this call would only be needed
// if we had previously disabled the doppler effect on this audio.
audio:EnableDoppler()

EnableListenerDoppler()

EnableListenerDoppler will make the audio engine consider the velocity of the listener when calculating doppler effects. The listener is universal to all audio objects, which means that if you enable doppler calculations for the listener, it will enable it when calculating doppler for ALL audio objects. By default, the listener already has doppler enabled, but this will have no effect until the listener is given a velocity.

Example



use Libraries.Sound.Audio

Audio audio
audio:Load("Whale.wav")

// In order to hear the doppler effect in action, the listener needs
// to have velocity.
audio:SetListenerVelocity(5, 0, 4)

// We now enable the doppler effect for the listener -- by default, this
// is already on, so this is only needed if we'd previously disabled it.
audio:EnableListenerDoppler()

EnableLooping()

EnableLooping will set the audio to continuously repeat itself when reaching the end of the audio instead of stopping.

Example



use Libraries.Sound.Audio

// To use audio, we'll first need to create an object for it.
Audio audio

// We need to load our audio before we change whether or not it will loop.
audio:Load("test.wav")

// We now enable looping. This will make the sound repeat forever until we
// stop it or call "audio:DisableLooping()".
audio:EnableLooping()

EnablePhysics(boolean flag)

This action will return the global y coordinate of the Item3D. This is the item's position plus any offset applied by its relation to its parent (if it has one).

Parameters

  • boolean flag

Example

use Libraries.Interface.Item3D
Item3D myItem
Item3D parentItem
parentItem:SetY(50)
myItem:SetY(25)
parentItem:Add(myItem)
number y = myItem:GetGlobalY()

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)

FastMoving(boolean flag)

This action sets the x, y, and z coordinates of the Item3D.

Parameters

  • boolean flag

Example

use Libraries.Interface.Item3D
Item3D myItem
myItem:SetPosition(50, 200, 35)