SpriteBatch#SpriteBatch

new SpriteBatch(game, parent, name, addToStage)

The SpriteBatch class is a really fast version of the DisplayObjectContainer built purely for speed, so use when you need a lot of sprites or particles.
It's worth mentioning that by default sprite batches are used through-out the renderer, so you only really need to use a SpriteBatch if you have over
1000 sprites that all share the same texture (or texture atlas). It's also useful if running in Canvas mode and you have a lot of un-rotated or un-scaled
Sprites as it skips all of the Canvas setTransform calls, which helps performance, especially on mobile devices.

Please note that any Sprite that is part of a SpriteBatch will not have its bounds updated, so will fail checks such as outOfBounds.

Parameters
Name Type Argument Default Description
game Phaser.Game

A reference to the currently running game.

parent Phaser.Group | Phaser.Sprite | null

The parent Group, DisplayObject or DisplayObjectContainer that this Group will be added to. If undefined or null it will use game.world.

name string <optional>
group

A name for this Group. Not used internally but useful for debugging.

addToStage boolean <optional>
false

If set to true this Group will be added directly to the Game.Stage instead of Game.World.

Source code: gameobjects/SpriteBatch.js (Line 23)
doc_phaser
2017-02-14 11:12:31
Comments
Leave a Comment

Please login to continue.