2017-01-24 18:08:56 +00:00
|
|
|
|
2017-02-23 03:54:54 +00:00
|
|
|
var Class = require('../../utils/Class');
|
2017-01-24 18:08:56 +00:00
|
|
|
var GameObject = require('../GameObject');
|
2017-02-23 03:54:54 +00:00
|
|
|
var Components = require('../../components');
|
|
|
|
var SpriteRender = require('./SpriteRender');
|
|
|
|
|
|
|
|
var Sprite = new Class({
|
|
|
|
|
2017-04-05 01:10:48 +00:00
|
|
|
Extends: GameObject,
|
|
|
|
|
2017-02-23 03:54:54 +00:00
|
|
|
Mixins: [
|
|
|
|
Components.Alpha,
|
|
|
|
Components.BlendMode,
|
2017-04-04 22:59:16 +00:00
|
|
|
Components.Flip,
|
2017-03-02 02:06:13 +00:00
|
|
|
Components.GetBounds,
|
|
|
|
Components.Origin,
|
2017-02-23 03:54:54 +00:00
|
|
|
Components.ScaleMode,
|
2017-03-02 02:06:13 +00:00
|
|
|
Components.Size,
|
|
|
|
Components.Texture,
|
|
|
|
Components.Transform,
|
2017-02-23 03:54:54 +00:00
|
|
|
Components.Visible,
|
|
|
|
SpriteRender
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
|
|
|
function Sprite (state, x, y, texture, frame)
|
|
|
|
{
|
|
|
|
GameObject.call(this, state);
|
|
|
|
|
2017-04-04 22:59:16 +00:00
|
|
|
this.anims = new Components.Animation(this);
|
|
|
|
|
2017-02-23 03:54:54 +00:00
|
|
|
this.setTexture(texture, frame);
|
2017-03-02 02:06:13 +00:00
|
|
|
this.setPosition(x, y);
|
2017-03-02 04:00:39 +00:00
|
|
|
this.setSizeToFrame();
|
2017-03-15 23:44:39 +00:00
|
|
|
this.setOrigin();
|
2017-04-04 22:59:16 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
preUpdate: function (timestamp, frameDelta)
|
|
|
|
{
|
|
|
|
this.anims.update(timestamp, frameDelta);
|
2017-01-24 18:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = Sprite;
|