2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2017-11-09 04:01:58 +00:00
|
|
|
var Class = require('../../utils/Class');
|
|
|
|
var Components = require('./components');
|
|
|
|
var Sprite = require('../../gameobjects/sprite/Sprite');
|
|
|
|
|
2018-02-09 03:44:23 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
|
|
|
* An Arcade 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.
|
|
|
|
*
|
|
|
|
* @class Sprite
|
|
|
|
* @extends Phaser.GameObjects.Sprite
|
|
|
|
* @memberOf Phaser.Physics.Arcade
|
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Acceleration
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Angular
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Bounce
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Debug
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Drag
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Enable
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Friction
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Gravity
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Immovable
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Mass
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Size
|
|
|
|
* @extends Phaser.Physics.Arcade.Components.Velocity
|
|
|
|
* @extends Phaser.GameObjects.Components.Alpha
|
|
|
|
* @extends Phaser.GameObjects.Components.BlendMode
|
|
|
|
* @extends Phaser.GameObjects.Components.Depth
|
|
|
|
* @extends Phaser.GameObjects.Components.Flip
|
|
|
|
* @extends Phaser.GameObjects.Components.GetBounds
|
|
|
|
* @extends Phaser.GameObjects.Components.Origin
|
|
|
|
* @extends Phaser.GameObjects.Components.Pipeline
|
|
|
|
* @extends Phaser.GameObjects.Components.ScaleMode
|
|
|
|
* @extends Phaser.GameObjects.Components.ScrollFactor
|
|
|
|
* @extends Phaser.GameObjects.Components.Size
|
|
|
|
* @extends Phaser.GameObjects.Components.Texture
|
|
|
|
* @extends Phaser.GameObjects.Components.Tint
|
|
|
|
* @extends Phaser.GameObjects.Components.Transform
|
|
|
|
* @extends Phaser.GameObjects.Components.Visible
|
|
|
|
*
|
|
|
|
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
|
|
|
|
* @param {number} x - The horizontal position of this Game Object in the world.
|
|
|
|
* @param {number} y - The vertical position of this Game Object in the world.
|
|
|
|
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
|
2018-03-20 15:10:19 +00:00
|
|
|
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
|
2018-02-09 03:44:23 +00:00
|
|
|
*/
|
2017-11-09 04:01:58 +00:00
|
|
|
var ArcadeSprite = new Class({
|
|
|
|
|
|
|
|
Extends: Sprite,
|
|
|
|
|
|
|
|
Mixins: [
|
|
|
|
Components.Acceleration,
|
|
|
|
Components.Angular,
|
|
|
|
Components.Bounce,
|
|
|
|
Components.Debug,
|
|
|
|
Components.Drag,
|
2017-12-03 11:06:21 +00:00
|
|
|
Components.Enable,
|
2017-11-09 04:01:58 +00:00
|
|
|
Components.Friction,
|
|
|
|
Components.Gravity,
|
|
|
|
Components.Immovable,
|
|
|
|
Components.Mass,
|
|
|
|
Components.Size,
|
|
|
|
Components.Velocity
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-11-09 16:31:26 +00:00
|
|
|
function ArcadeSprite (scene, x, y, texture, frame)
|
2017-11-09 04:01:58 +00:00
|
|
|
{
|
|
|
|
Sprite.call(this, scene, x, y, texture, frame);
|
2018-05-22 02:16:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If this Game Object is enabled for physics then this property will contain a reference to a Physics Body.
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Sprite#body
|
|
|
|
* @type {?Phaser.Physics.Arcade.Body}
|
|
|
|
* @default null
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
|
|
|
this.body = null;
|
2017-11-09 04:01:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = ArcadeSprite;
|