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
| name | type | optional | description |
|---|---|---|---|
| scene | Phaser.Scene | No | The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. |
| x | number | No | The horizontal position of this Game Object in the world. |
| y | number | No | The vertical position of this Game Object in the world. |
| texture | string | Phaser.Textures.Texture | No | The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. |
| frame | string | number | Yes | An 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:
- filterCamera
- filters
- filtersAutoFocus
- filtersFocusContext
- filtersForceComposite
- maxFilterSize
- renderFilters
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:
- active
- cameraFilter
- data
- displayList
- ignoreDestroy
- input
- isDestroyed
- name
- parentContainer
- renderFlags
- scene
- state
- tabIndex
- type
- vertexRoundMode
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:
- addListener
- emit
- eventNames
- listenerCount
- listeners
- off
- on
- once
- removeAllListeners
- removeListener
- shutdown
From Phaser.GameObjects.Components.Alpha:
From Phaser.GameObjects.Components.BlendMode:
From Phaser.GameObjects.Components.Depth:
From Phaser.GameObjects.Components.Filters:
- enableFilters
- focusFilters
- focusFiltersOnCamera
- focusFiltersOverride
- renderWebGLFilters
- setFiltersAutoFocus
- setFiltersFocusContext
- setFiltersForceComposite
- setFilterSize
- setRenderFilters
- willRenderFilters
From Phaser.GameObjects.Components.Flip:
From Phaser.GameObjects.Components.GetBounds:
- getBottomCenter
- getBottomLeft
- getBottomRight
- getBounds
- getCenter
- getLeftCenter
- getRightCenter
- getTopCenter
- getTopLeft
- getTopRight
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:
- copyPosition
- getLocalPoint
- getLocalTransformMatrix
- getParentRotation
- getWorldPoint
- getWorldTransformMatrix
- setAngle
- setPosition
- setRandomPosition
- setRotation
- setScale
- setW
- setX
- setY
- setZ
From Phaser.GameObjects.Components.Visible:
From Phaser.GameObjects.GameObject:
- addToDisplayList
- addToUpdateList
- destroy
- disableInteractive
- getData
- getDisplayList
- getIndexList
- incData
- removeFromDisplayList
- removeFromUpdateList
- removeInteractive
- setActive
- setData
- setDataEnabled
- setInteractive
- setName
- setState
- setVertexRoundMode
- toggleData
- update
- willRender
- willRoundVertices
From Phaser.GameObjects.Sprite:
- addedToScene
- chain
- play
- playAfterDelay
- playAfterRepeat
- playReverse
- preUpdate
- removedFromScene
- stop
- stopAfterDelay
- stopAfterRepeat
- stopOnFrame
- toJSON
From Phaser.Physics.Arcade.Components.Acceleration:
From Phaser.Physics.Arcade.Components.Angular:
From Phaser.Physics.Arcade.Components.Bounce:
From Phaser.Physics.Arcade.Components.Collision:
- addCollidesWith
- removeCollidesWith
- resetCollisionCategory
- setCollidesWith
- setCollisionCategory
- willCollideWith
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: