Skip to main content
Version: Phaser v4.0.0-rc.6

Sprite

A Matter Physics Sprite Game Object.

A Sprite Game Object is used for the display of both static and animated images in your game.

Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled

and animated.

The main difference between a Sprite and an Image Game Object is that you cannot animate Images.

As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation

Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.

Constructor

new Sprite(world, x, y, texture, [frame], [options])

Parameters

nametypeoptionaldescription
worldPhaser.Physics.Matter.WorldNoA reference to the Matter.World instance that this body belongs to.
xnumberNoThe horizontal position of this Game Object in the world.
ynumberNoThe vertical position of this Game Object in the world.
texturestring | Phaser.Textures.TextureNoThe key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
framestring | numberYesAn optional frame from the Texture this Game Object is rendering with.
optionsPhaser.Types.Physics.Matter.MatterBodyConfigYesAn optional Body configuration object that is used to set initial Body properties on creation.

Scope: static

Extends

Phaser.GameObjects.Sprite
Phaser.Physics.Matter.Components.Bounce
Phaser.Physics.Matter.Components.Collision
Phaser.Physics.Matter.Components.Force
Phaser.Physics.Matter.Components.Friction
Phaser.Physics.Matter.Components.Gravity
Phaser.Physics.Matter.Components.Mass
Phaser.Physics.Matter.Components.Sensor
Phaser.Physics.Matter.Components.SetBody
Phaser.Physics.Matter.Components.Sleep
Phaser.Physics.Matter.Components.Static
Phaser.Physics.Matter.Components.Transform
Phaser.Physics.Matter.Components.Velocity
Phaser.GameObjects.Components.Alpha
Phaser.GameObjects.Components.BlendMode
Phaser.GameObjects.Components.Depth
Phaser.GameObjects.Components.Flip
Phaser.GameObjects.Components.GetBounds
Phaser.GameObjects.Components.Mask
Phaser.GameObjects.Components.Origin
Phaser.GameObjects.Components.ScrollFactor
Phaser.GameObjects.Components.Size
Phaser.GameObjects.Components.Texture
Phaser.GameObjects.Components.Tint
Phaser.GameObjects.Components.Transform
Phaser.GameObjects.Components.Visible

Source: src/physics/matter-js/MatterSprite.js#L15
Since: 3.0.0

Inherited Members

From Phaser.GameObjects.Components.Alpha:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.Filters:

From Phaser.GameObjects.Components.Flip:

From Phaser.GameObjects.Components.Lighting:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.Origin:

From Phaser.GameObjects.Components.RenderNodes:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Size:

From Phaser.GameObjects.Components.TextureCrop:

From Phaser.GameObjects.Components.Tint:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:

From Phaser.GameObjects.Sprite:

From Phaser.Physics.Matter.Components.Mass:


Public Members

world

world: Phaser.Physics.Matter.World

Description:

A reference to the Matter.World instance that this body belongs to.

Source: src/physics/matter-js/MatterSprite.js#L108
Since: 3.0.0


Inherited Methods

From Phaser.Events.EventEmitter:

From Phaser.GameObjects.Components.Alpha:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.Filters:

From Phaser.GameObjects.Components.Flip:

From Phaser.GameObjects.Components.GetBounds:

From Phaser.GameObjects.Components.Lighting:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.Origin:

From Phaser.GameObjects.Components.RenderNodes:

From Phaser.GameObjects.Components.RenderSteps:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Size:

From Phaser.GameObjects.Components.TextureCrop:

From Phaser.GameObjects.Components.Tint:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:

From Phaser.GameObjects.Sprite:

From Phaser.Physics.Matter.Components.Bounce:

From Phaser.Physics.Matter.Components.Collision:

From Phaser.Physics.Matter.Components.Force:

From Phaser.Physics.Matter.Components.Friction:

From Phaser.Physics.Matter.Components.Gravity:

From Phaser.Physics.Matter.Components.Mass:

From Phaser.Physics.Matter.Components.Sensor:

From Phaser.Physics.Matter.Components.SetBody:

From Phaser.Physics.Matter.Components.Sleep:

From Phaser.Physics.Matter.Components.Static:

From Phaser.Physics.Matter.Components.Transform:

From Phaser.Physics.Matter.Components.Velocity: