BitmapData#generateTexture()

generateTexture(key) → {PIXI.Texture}

Creates a new Image element by converting this BitmapDatas canvas into a dataURL.

The image is then stored in the image Cache using the key given.

Finally a PIXI.Texture is created based on the image and returned.

You can apply the texture to a sprite or any other supporting object by using either the
key or the texture. First call generateTexture:

var texture = bitmapdata.generateTexture('ball');

Then you can either apply the texture to a sprite:

game.add.sprite(0, 0, texture);

or by using the string based key:

game.add.sprite(0, 0, 'ball');

Parameters
Name Type Description
key string

The key which will be used to store the image in the Cache.

Returns

The newly generated texture.

Source code: gameobjects/BitmapData.js (Line 516)
doc_phaser
2017-02-14 10:37:00
Comments
Leave a Comment

Please login to continue.