WebGLBatch Class
A WebGLBatch Enables a group of sprites to be drawn using the same settings. if a group of sprites all have the same baseTexture and blendMode then they can be grouped into a batch. All the sprites in a batch can then be drawn in one go by the GPU which is hugely efficient. ALL sprites in the webGL renderer are added to a batch even if the batch only contains one sprite. Batching is handled automatically by the webGL renderer. A good tip is: the smaller the number of batchs there are, the faster the webGL renderer will run.
Item Index
Methods
Methods
init
-
sprite
inits the batch's texture and blend mode based if the supplied sprite
Parameters:
-
sprite
Spritethe first sprite to be added to the batch. Only sprites with the same base texture and blend mode will be allowed to be added to this batch
insertAfter
-
sprite
-
previousSprite
inserts a sprite after the specified sprite
insertBefore
-
sprite
-
nextSprite
inserts a sprite before the specified sprite
Parameters:
-
sprite
Spritethe sprite to be added
-
nextSprite
NextSpritethe first sprite will be inserted before this sprite
merge
-
batch
Merges two batchs together
Parameters:
-
batch
WebGLBatchthe batch that will be merged
refresh
()
Refresh's all the data in the batch and sync's it with the webGL buffers
remove
-
sprite
removes a sprite from the batch
Parameters:
-
sprite
Spritethe sprite to be removed
render
()
Draws the batch to the frame buffer
split
-
sprite
Splits the batch into two with the specified sprite being the start of the new batch.
Parameters:
-
sprite
Spritethe sprite that indicates where the batch should be split
Returns:
update
()
Updates all the relevant geometry and uploads the data to the GPU