new SpriteBin() → {MC.SpriteBin}
Creates new SpriteBin object.
SpriteBin's provide a useful set of functions for the easy management of Sprite Collections.
SpriteBin's sizes are adjusted as necessary at run-time.
This:
Properties:
Name | Type | Description |
---|---|---|
bin |
Array | The internal array holding the Sprites |
clean |
Boolean | Internal flag to trigger cleanBin() |
Returns:
A new SpriteBin object
- Type
- MC.SpriteBin
Methods
bounce(targetopt) → {this}
Cycles through the Spritebin and calls the bounce() method of each Sprite against the target Parameter
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
target |
MC.Sprite | MC.SpriteBin |
<optional> |
self | Target for the bounce() call
If omitted, each Sprite in the bin will be bounced off each other If an MC.Sprite, target is a single sprite If a SpriteBin, each Sprite in the calling bin will be bounced off all the Sprites in the target bin. WARNING: this last simple call can have a huge performance hit if Spritebins (and/or number of physicsUpdates) are large |
Returns:
Enables method chaining.
- Type
- this
cleanBin()
Cycles through all Sprites in the bin and removes any which are null or where Sprite.dead == true
Called automatically at the end of any render() call should update() have found any candidates for deletion
empty() → {this}
Empties the bin of everything. Useful for game or level resets
The SpriteBin itself is still available for use
Returns:
Enabled Method Chaining
- Type
- this
pop() → {this}
Removes the last object from the SpriteBin list
Returns:
Enabled Method Chaining
- Type
- this
push(sprites) → {this}
Adds Sprite(s) to the END of the SpriteBin list
Parameters:
Name | Type | Description |
---|---|---|
sprites |
MC.Sprite | Comma seperated list of sprite(s)
N.B. Non-sprites will be ignored |
Returns:
Enabled Method Chaining
- Type
- this
render() → {this}
Calls the render() function on each Object in the SpriteBin (if it has it) so it is drawn on the game canvas
Returns:
Enables Method chaining
- Type
- this
update(deltaTimeopt) → {this}
Calls the update() function on each Object in the SpriteBin (if it has it). Elements with null or Sprites with .dead == True are flagged to require clean up.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
deltaTime |
Number |
<optional> |
MC.game.deltaTime | DeltaTime (before any physicsUpdates calculation) in Seconds. |
Returns:
Enables Method chaining
- Type
- this