Constructor
new DisplayGroup(container)
Creates a new instance of the DisplayGroup class.
Parameters:
Name | Type | Description |
---|---|---|
container |
rune.display.DisplayObjectContainer | Display object container object that will contain members. |
- Source:
Members
active :boolean
Whether the group is active (true) or not (false). Inactive groups are
not automatically updated by the group manager.
Type:
- boolean
- Default Value:
- true
- Source:
(readonly) application :rune.system.Main
Reference to the application's entry point class, ie. the main class of the
application. Useful for accessing the application's subsystem.
Type:
- rune.system.Main
- Source:
(readonly) cameras :rune.camera.Cameras
Reference to the current scene's camera system.
Type:
- Source:
(readonly) container :rune.display.DisplayObject
Reference to the display object container to which the group is linked. When
new members are added to the group, they are also added to the display
object container's display list.
Type:
- Source:
(readonly) gamepads :rune.input.Gamepads
Reference to the application's subsystem for connected gamepad devices.
Type:
- Source:
(readonly) keyboard :rune.input.Keyboard
Reference to the subsystem representing the keyboard input.
Type:
- Source:
(readonly) numMembers :number
The number of members included in the group. Note that this number is not
necessarily the same as the number of children in the display object
container to which the group is linked.
Type:
- number
- Source:
useQuadtree :boolean
Whether the group should use a quad tree to improve hit testing performance.
Note that the quad tree can not guarantee noticeably better performance, but
it should be evaluated when you experience performance problems with the
quad tree disabled.
Type:
- boolean
- Source:
Methods
addMember(member) → {boolean}
Adds a member to the display group. Note that attempts to add existing
members are denied. The method always returns a boolean that indicates
whether the extension was successful (true) or not (false). When an item is
added to a group, it is automatically removed from any other groups, and it
is also removed from other display lists. This means that an object can only
be a member of one group at a time and that it is always available in the
group's container object view list as long as it is a member of that group.
Parameters:
Name | Type | Description |
---|---|---|
member |
rune.display.DisplayObject | Prospect to add. |
- Source:
Returns:
- Type
- boolean
dispose() → {undefined}
This method is called automatically just before the group is destroyed.
Override the method for creating your own deallocation code, ie code that
deletes objects created by the group.
- Source:
Returns:
- Type
- undefined
forEachMember(callback, scope) → {undefined}
Executes a callback method for each member of the group. Reference to the
current member and its member index are sent to the callback method as
arguments.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Call function. |
scope |
Object | Scope of execution. |
- Source:
Returns:
- Type
- undefined
getMemberAt(index) → {rune.display.DisplayObject}
Retrieves a member object at a specific index. Note that the member index is
not necessarily the same as the object's child index in the display object
container.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | The index position of the member object. |
- Source:
Throws:
-
Throws if the index does not exist in the member list.
- Type
- RangeError
Returns:
The member object at the specified index position.
getMembers() → {Array.<rune.display.DisplayObject>}
Retrieves the list of all members. This method is primarily intended for
internal use. Consider it read-only, as changes in the structure can cause
problems for the group.
- Source:
Returns:
- Type
- Array.<rune.display.DisplayObject>
getMembersCloseTo(obj) → {Array.<rune.display.DisplayObject>}
If the useQuadtree property is set to true, only member objects that are in
close proximity to the argument object are returned; otherwise a list of all
members is returned.
Parameters:
Name | Type | Description |
---|---|---|
obj |
rune.display.DisplayObject | Main object. |
- Source:
Returns:
- Type
- Array.<rune.display.DisplayObject>
hasMember(prospect) → {boolean}
Returns whether an object is a member of the group (true) or not (false.)
Parameters:
Name | Type | Description |
---|---|---|
prospect |
rune.display.DisplayObject | Main object. |
- Source:
Returns:
- Type
- boolean
hitTest(obj, callbackopt, scopeopt) → {boolean}
Performs hit detection between an object and all members of the group. For
each hit, a callback method is also executed, which attaches the two objects
that collide as arguments to the method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
rune.display.DisplayObject | rune.display.DisplayGroup | rune.geom.Point | Array | Object to test against. | |
callback |
function |
<optional> |
Method that is called when a collision is detected. |
scope |
Object |
<optional> |
Scope of execution of the callback method. |
- Source:
Returns:
Returns true if any hit was found, otherwise false.
- Type
- boolean
hitTestAndSeparate(obj, callbackopt, scopeopt) → {boolean}
Performs hit detection between an object and all members of the group. If a
hit is detected, the objects are separated according to their physical
properties. For each hit, a callback method is also executed, which attaches
the two objects that collide as arguments to the method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
rune.display.DisplayObject | rune.display.DisplayGroup | Array | Object to test against. | |
callback |
function |
<optional> |
Method that is called when a collision is detected. |
scope |
Object |
<optional> |
Scope of execution of the callback method. |
- Source:
Returns:
Returns true if any hit was found, otherwise false.
- Type
- boolean
hitTestAndSeparateContentOf(array, callbackopt, scopeopt) → {boolean}
Evaluates and handles collisions between group member hitboxes and the
hitboxes of objects in an array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
array |
Array | The array to test against. | |
callback |
function |
<optional> |
Method that is called when a collision is detected. |
scope |
Object |
<optional> |
Scope of execution of the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestAndSeparateGroup(group, callbackopt, scopeopt) → {boolean}
Performs hit detection between members of this and another group. If a hit
is detected, the objects are separated based on their physical properties.
For each hit, a callback method is also executed, which attaches the two
objects that collide as arguments to the method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
group |
rune.display.DisplayGroup | Group to test against. | |
callback |
function |
<optional> |
Method that is called when a collision is detected. |
scope |
Object |
<optional> |
Scope of execution of the callback method. |
- Source:
Returns:
True if there was a collision, otherwise false.
- Type
- boolean
hitTestAndSeparateObject(obj, callbackopt, scopeopt) → {boolean}
Performs hit detection between members of this group and another display
object. If a hit is detected, the objects are separated based on their
physical properties. For each hit, a callback method is also executed, which
attaches the two objects that collide as arguments to the method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
rune.display.DisplayObject | Object to test against. | |
callback |
function |
<optional> |
Method that is called when a collision is detected. |
scope |
Object |
<optional> |
Scope of execution of the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestContentOf(array, callbackopt, scopeopt) → {boolean}
Evaluates collision between the hitboxes of group members and the hitboxes
of objects in an array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
array |
Array | The array to test against. | |
callback |
function |
<optional> |
Method that is called when a collision is detected. |
scope |
Object |
<optional> |
Scope of execution of the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestGroup(group, callbackopt, scopeopt) → {boolean}
Hit detect all members of the group against the members of (the same or)
another group.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
group |
rune.display.DisplayGroup | The group to test against. | |
callback |
function |
<optional> |
Method that is called when a collision is detected. |
scope |
Object |
<optional> |
Scope of execution of the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestObject(obj, callbackopt, scopeopt) → {boolean}
Hit detect all members of the group against another display object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
rune.display.DisplayObject | The display object to test against. | |
callback |
function |
<optional> |
Method that is called when a collision is detected. |
scope |
Object |
<optional> |
Scope of execution of the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestPoint(point, callbackopt, scopeopt) → {boolean}
Hit Detect all members of the group against a point. The method returns true
if the point overlaps one of the group members, otherwise false is returned.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
point |
rune.geom.Point | Point to test against. | |
callback |
function |
<optional> |
Method that is called when a collision is detected. |
scope |
Object |
<optional> |
Scope of execution of the callback method. |
- Source:
Returns:
- Type
- boolean
init() → {undefined}
This method is automatically called once by the group manager when the group
is created, or added. The method is public but should be considered
internal. External calls should only be made if 1. The group is disabled, or
2. If the group is not added to a manager.
- Source:
Returns:
- Type
- undefined
postUpdate(step) → {undefined}
This method is called automatically after the group's main update method is
completed. The method can be overridden and used to complete closing
processes just before the next update.
Parameters:
Name | Type | Description |
---|---|---|
step |
number | Current time step. |
- Source:
Returns:
- Type
- undefined
preUpdate(step) → {undefined}
This method is called just before the group's update method and performs
processes that must be completed before the group's main update process
begins. Avoid overriding and modifying this method.
Parameters:
Name | Type | Description |
---|---|---|
step |
number | Current time step. |
- Source:
Returns:
- Type
- undefined
removeMember(member, dispose) → {rune.display.DisplayObject}
Removes a member from the group. Note that the member will also be removed
from the display object's display list. It is not possible to be a member
of the group without being available in the container object's display list.
Parameters:
Name | Type | Description |
---|---|---|
member |
rune.display.DisplayObject | Member to be removed. |
dispose |
boolean | Whether the member should be destroyed when it is removed. |
- Source:
Returns:
removeMembers(dispose) → {undefined}
Removes all members from the group.
Parameters:
Name | Type | Description |
---|---|---|
dispose |
boolean | Whether the members should be destroyed when they are removed. |
- Source:
Returns:
- Type
- undefined
update(step) → {undefined}
This method represents the group's main update process. The method can be
overridden in order to add custom logic.
Parameters:
Name | Type | Description |
---|---|---|
step |
number | Current time step. |
- Source:
Returns:
- Type
- undefined