phaser/wip/gameobjects/spritebatch/SpriteBatch.js

52 lines
2.2 KiB
JavaScript
Raw Normal View History

/**
* @author Richard Davey <rich@photonstorm.com>
2016-04-04 21:15:01 +00:00
* @copyright 2016 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* 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.
*
2015-02-11 16:41:56 +00:00
* Please note that any Sprite that is part of a SpriteBatch will not have its bounds updated, so will fail checks such as outOfBounds.
*
* @class Phaser.GameObject.SpriteBatch
* @extends Phaser.Group
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {Phaser.Group|Phaser.Sprite|null} parent - The parent Group, DisplayObject or DisplayObjectContainer that this Group will be added to. If `undefined` or `null` it will use game.world.
* @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging.
* @param {boolean} [addToStage=false] - If set to true this Group will be added directly to the Game.Stage instead of Game.World.
*/
Phaser.GameObject.SpriteBatch = function (game, parent, name, addToStage) {
if (parent === undefined || parent === null) { parent = game.world; }
// Phaser.Group.call(this, game, parent, name, addToStage);
/**
* @property {number} type - Internal Phaser Type value.
* @protected
*/
this.type = Phaser.SPRITEBATCH;
2016-09-27 22:22:26 +00:00
/**
* @property {Object} fastSpriteBatch - WebGL Batch Shader.
* @private
*/
this.fastSpriteBatch = null;
/**
* @property {boolean} ready - Internal flag.
* @private
*/
2016-09-27 22:20:38 +00:00
this.ready = false;
};
// Phaser.GameObject.SpriteBatch.prototype = Object.create(Phaser.Group.prototype);
Phaser.GameObject.SpriteBatch.prototype.constructor = Phaser.GameObject.SpriteBatch;