new Sprite(game, x, y, key, frame)
Sprites are the lifeblood of your game, used for nearly everything visual.
At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas.
They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input),
events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases.
Parameters
Name | Type | Description |
---|---|---|
game | Phaser.Game | A reference to the currently running game. |
x | number | The x coordinate (in world space) to position the Sprite at. |
y | number | The y coordinate (in world space) to position the Sprite at. |
key | string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture | This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. |
frame | string | number | If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. |
- Source code: gameobjects/Sprite.js (Line 44)
Please login to continue.