draw(source, x, y, width, height, blendMode, roundPx) → {Phaser.BitmapData}
Draws the given Phaser.Sprite, Phaser.Image or Phaser.Text to this BitmapData at the coordinates specified.
You can use the optional width and height values to 'stretch' the sprite as it is drawn. This uses drawImage stretching, not scaling.
The children will be drawn at their x
and y
world space coordinates. If this is outside the bounds of the BitmapData they won't be visible.
When drawing it will take into account the rotation, scale, scaleMode, alpha and tint values.
Note: You should ensure that at least 1 full update has taken place before calling this,
otherwise the objects are likely to render incorrectly, if at all.
You can trigger an update yourself by calling stage.updateTransform()
before calling draw
.
Parameters
Name | Type | Argument | Default | Description |
---|---|---|---|---|
source | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.RenderTexture | The Sprite, Image or Text object to draw onto this BitmapData. | ||
x | number | <optional> | 0 | The x coordinate to translate to before drawing. If not specified it will default to |
y | number | <optional> | 0 | The y coordinate to translate to before drawing. If not specified it will default to |
width | number | <optional> | The new width of the Sprite being copied. If not specified it will default to | |
height | number | <optional> | The new height of the Sprite being copied. If not specified it will default to | |
blendMode | string | <optional> | null | The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. |
roundPx | boolean | <optional> | false | Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. |
Returns
This BitmapData object for method chaining.
- Source code: gameobjects/BitmapData.js (Line 1553)
Please login to continue.