Skip to main content
Version: Phaser v4.0.0

Sprite

An Arcade Physics Sprite is a Sprite with an Arcade Physics body and related components. Arcade Physics provides a lightweight, fast AABB (axis-aligned bounding box) and circle-based collision system suited for most 2D game needs.

The physics body can be either dynamic (affected by velocity, acceleration, and gravity) or static (fixed in place, immovable by other bodies). Once the sprite is added to an Arcade Physics group or the world, its body property is populated and you can control movement, apply forces, set collision bounds, and respond to overlap and collider callbacks.

The main difference between an Arcade Sprite and an Arcade Image is that you cannot animate an Arcade Image. If you do not require animation then you can safely use Arcade Images instead of Arcade Sprites.

Constructor

new Sprite(scene, x, y, texture, [frame])

Parameters

nametypeoptionaldescription
scenePhaser.SceneNoThe Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
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.

Scope: static

Extends

Phaser.GameObjects.Sprite
Phaser.Physics.Arcade.Components.Acceleration
Phaser.Physics.Arcade.Components.Angular
Phaser.Physics.Arcade.Components.Bounce
Phaser.Physics.Arcade.Components.Collision
Phaser.Physics.Arcade.Components.Debug
Phaser.Physics.Arcade.Components.Drag
Phaser.Physics.Arcade.Components.Enable
Phaser.Physics.Arcade.Components.Friction
Phaser.Physics.Arcade.Components.Gravity
Phaser.Physics.Arcade.Components.Immovable
Phaser.Physics.Arcade.Components.Mass
Phaser.Physics.Arcade.Components.Pushable
Phaser.Physics.Arcade.Components.Size
Phaser.Physics.Arcade.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/arcade/ArcadeSprite.js#L11
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.Arcade.Components.Debug:


Public Members

body

body: Phaser.Physics.Arcade.Body, Phaser.Physics.Arcade.StaticBody

Description:

The Arcade Physics Body attached to this Game Object. This is set automatically when the sprite is added to an Arcade Physics group or enabled via physics.add.existing. Use this reference to apply velocity, acceleration, gravity, and other physics properties. It will be either a dynamic Body (the default) or a StaticBody if the sprite was created as a static physics object.

Overrides: Phaser.GameObjects.Sprite#body

Source: src/physics/arcade/ArcadeSprite.js#L92
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.Arcade.Components.Acceleration:

From Phaser.Physics.Arcade.Components.Angular:

From Phaser.Physics.Arcade.Components.Bounce:

From Phaser.Physics.Arcade.Components.Collision:

From Phaser.Physics.Arcade.Components.Debug:

From Phaser.Physics.Arcade.Components.Drag:

From Phaser.Physics.Arcade.Components.Enable:

From Phaser.Physics.Arcade.Components.Friction:

From Phaser.Physics.Arcade.Components.Gravity:

From Phaser.Physics.Arcade.Components.Immovable:

From Phaser.Physics.Arcade.Components.Mass:

From Phaser.Physics.Arcade.Components.Pushable:

From Phaser.Physics.Arcade.Components.Size:

From Phaser.Physics.Arcade.Components.Velocity: