new BitmapData(game, key, width, height)
Creates a new BitmapData object.
Parameters:
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
||
key |
string | Internal Phaser reference key for the render texture. |
||
width |
number |
<optional> |
100 | The width of the BitmapData in pixels. |
height |
number |
<optional> |
100 | The height of the BitmapData in pixels. |
- Source:
Members
-
baseTexture
-
- Source:
Properties:
Name Type Description baseTexturePIXI.BaseTexture The PIXI.BaseTexture.
-
canvas
-
- Source:
Properties:
Name Type Description canvasHTMLCanvasElement The canvas to which this BitmapData draws.
-
context
-
- Source:
Properties:
Name Type Description contextCanvasRenderingContext2D The 2d context of the canvas.
-
ctx
-
- Source:
Properties:
Name Type Description ctxCanvasRenderingContext2D A reference to BitmapData.context.
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game A reference to the currently running game.
-
height
-
- Source:
Properties:
Name Type Description heightnumber The height of the BitmapData in pixels.
-
imageData
-
- Source:
Properties:
Name Type Description imageDataarray The canvas image data.
-
key
-
- Source:
Properties:
Name Type Description keystring The key of the BitmapData in the Cache, if stored there.
-
pixels
-
- Source:
Properties:
Name Type Description pixelsUInt8Clamped A reference to the context imageData buffer.
-
texture
-
- Source:
Properties:
Name Type Description texturePIXI.Texture The PIXI.Texture.
-
textureFrame
-
- Source:
Properties:
Name Type Description textureFramePhaser.Frame The Frame this BitmapData uses for rendering.
-
type
-
- Source:
Properties:
Name Type Description typenumber The const type of this object.
-
width
-
- Source:
Properties:
Name Type Description widthnumber The width of the BitmapData in pixels.
Methods
-
add(object)
-
Updates the given objects so that they use this BitmapData as their texture. This will replace any texture they will currently have set.
Parameters:
Name Type Description objectPhaser.Sprite | Array.<Phaser.Sprite> | Phaser.Image | Array.<Phaser.Image> Either a single Sprite/Image or an Array of Sprites/Images.
- Source:
-
alphaMask(source, mask)
-
Draws the given image onto this BitmapData using an image as an alpha mask.
Parameters:
Name Type Description sourceHTMLImage | string The Image to draw. If you give a key it will try and find the Image in the Game.Cache.
maskHTMLImage | string The Image to use as the alpha mask. If you give a key it will try and find the Image in the Game.Cache.
- Source:
-
clear()
-
Clears the BitmapData.
- Source:
-
copyPixels(source, area, destX, destY)
-
Copies the pixels from the source image to this BitmapData based on the given area and destination.
Parameters:
Name Type Description sourceHTMLImage | string The Image to draw. If you give a key it will try and find the Image in the Game.Cache.
areaPhaser.Rectangle The Rectangle region to copy from the source image.
destXnumber The destination x coordinate to copy the image to.
destYnumber The destination y coordinate to copy the image to.
- Source:
-
draw(source, destX, destY)
-
Draws the given image to this BitmapData at the coordinates specified. If you need to only draw a part of the image use BitmapData.copyPixels instead.
Parameters:
Name Type Description sourceHTMLImage | string The Image to draw. If you give a key it will try and find the Image in the Game.Cache.
destXnumber The destination x coordinate to draw the image to.
destYnumber The destination y coordinate to draw the image to.
- Source:
-
getPixel(x, y) → {number}
-
Get the color of a specific pixel.
Parameters:
Name Type Description xnumber The X coordinate of the pixel to get.
ynumber The Y coordinate of the pixel to get.
- Source:
Returns:
A native color value integer (format: 0xRRGGBB)
- Type
- number
-
getPixel32(x, y) → {number}
-
Get the color of a specific pixel including its alpha value.
Parameters:
Name Type Description xnumber The X coordinate of the pixel to get.
ynumber The Y coordinate of the pixel to get.
- Source:
Returns:
A native color value integer (format: 0xAARRGGBB)
- Type
- number
-
getPixels(rect) → {array}
-
Gets all the pixels from the region specified by the given Rectangle object.
Parameters:
Name Type Description rectPhaser.Rectangle The Rectangle region to get.
- Source:
Returns:
CanvasPixelArray.
- Type
- array
-
refreshBuffer()
-
- Source:
-
render()
-
If the game is running in WebGL this will push the texture up to the GPU if it's dirty. This is called automatically if the BitmapData is being used by a Sprite, otherwise you need to remember to call it in your render function.
- Source:
-
resize()
-
Resizes the BitmapData.
- Source:
-
setPixel(x, y, red, green, blue)
-
Sets the color of the given pixel to the specified red, green and blue values.
Parameters:
Name Type Description xnumber The X coordinate of the pixel to be set.
ynumber The Y coordinate of the pixel to be set.
rednumber The red color value (between 0 and 255)
greennumber The green color value (between 0 and 255)
bluenumber The blue color value (between 0 and 255)
- Source:
-
setPixel32(x, y, red, green, blue, alpha)
-
Sets the color of the given pixel to the specified red, green, blue and alpha values.
Parameters:
Name Type Description xnumber The X coordinate of the pixel to be set.
ynumber The Y coordinate of the pixel to be set.
rednumber The red color value, between 0 and 0xFF (255).
greennumber The green color value, between 0 and 0xFF (255).
bluenumber The blue color value, between 0 and 0xFF (255).
alphanumber The alpha color value, between 0 and 0xFF (255).
- Source: