GameObjectFactory#sprite()

sprite(x, y, key, frame, group) → {Phaser.Sprite}

Create a new Sprite with specific position and sprite sheet key.

At its most basic a Sprite consists of a set of coordinates and a texture that is used when rendered.
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 Argument Default Description
x number <optional>
0

The x coordinate of the sprite. The coordinate is relative to any parent container this sprite may be in.

y number <optional>
0

The y coordinate of the sprite. The coordinate is relative to any parent container this sprite may be in.

key string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture <optional>

The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.

frame string | number <optional>

If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name.

group Phaser.Group <optional>

Optional Group to add the object to. If not specified it will be added to the World group.

Returns

The newly created Sprite object.

Source code: gameobjects/GameObjectFactory.js (Line 102)
doc_phaser
2017-02-14 10:48:47
Comments
Leave a Comment

Please login to continue.