2017-07-04 00:59:31 +00:00
|
|
|
var Class = require('../../utils/Class');
|
2017-01-24 12:55:45 +00:00
|
|
|
|
2017-07-04 00:59:31 +00:00
|
|
|
var Bob = new Class({
|
2017-02-13 23:57:32 +00:00
|
|
|
|
2017-07-04 00:59:31 +00:00
|
|
|
initialize:
|
2017-03-20 23:37:17 +00:00
|
|
|
|
2017-10-02 13:50:02 +00:00
|
|
|
function Bob (blitter, x, y, frame, visible)
|
2017-07-04 00:59:31 +00:00
|
|
|
{
|
2017-10-02 13:50:02 +00:00
|
|
|
this.parent = blitter;
|
2017-03-20 23:37:17 +00:00
|
|
|
|
2017-07-04 00:59:31 +00:00
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.frame = frame;
|
|
|
|
this.data = {};
|
2017-02-02 16:55:02 +00:00
|
|
|
|
2017-07-04 00:59:31 +00:00
|
|
|
this._visible = visible;
|
|
|
|
this._alpha = 1;
|
2017-02-13 23:57:32 +00:00
|
|
|
|
2017-07-04 00:59:31 +00:00
|
|
|
this.flipX - false;
|
|
|
|
this.flipY = false;
|
|
|
|
},
|
2017-02-13 23:57:32 +00:00
|
|
|
|
2018-01-20 16:21:42 +00:00
|
|
|
setFrame: function (frame)
|
|
|
|
{
|
|
|
|
if (frame === undefined)
|
|
|
|
{
|
|
|
|
frame = this.parent.frame;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frame = this.parent.texture.get(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-03-20 23:37:17 +00:00
|
|
|
resetFlip: function ()
|
|
|
|
{
|
|
|
|
this.flipX = false;
|
|
|
|
this.flipY = false;
|
|
|
|
},
|
|
|
|
|
2017-02-02 16:55:02 +00:00
|
|
|
reset: function (x, y, frame)
|
|
|
|
{
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.frame = frame;
|
2017-02-13 23:57:32 +00:00
|
|
|
},
|
|
|
|
|
2018-01-20 16:21:42 +00:00
|
|
|
setFlipX: function (value)
|
|
|
|
{
|
|
|
|
this.flipX = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setFlipY: function (value)
|
|
|
|
{
|
|
|
|
this.flipY = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setFlip: function (x, y)
|
|
|
|
{
|
|
|
|
this.flipX = x;
|
|
|
|
this.flipY = y;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setVisible: function (value)
|
|
|
|
{
|
|
|
|
this.visible = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setAlpha: function (value)
|
|
|
|
{
|
|
|
|
this.alpha = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-02-13 23:57:32 +00:00
|
|
|
destroy: function ()
|
|
|
|
{
|
2017-08-14 12:13:11 +00:00
|
|
|
this.parent.dirty = true;
|
|
|
|
|
|
|
|
this.parent.children.remove(this);
|
|
|
|
|
2017-02-13 23:57:32 +00:00
|
|
|
this.parent = undefined;
|
|
|
|
this.frame = undefined;
|
|
|
|
this.data = undefined;
|
2017-07-04 00:59:31 +00:00
|
|
|
},
|
2017-02-13 23:57:32 +00:00
|
|
|
|
|
|
|
visible: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this._visible;
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value)
|
|
|
|
{
|
|
|
|
this._visible = value;
|
|
|
|
this.parent.dirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
alpha: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this._alpha;
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value)
|
|
|
|
{
|
|
|
|
this._alpha = value;
|
|
|
|
this.parent.dirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-01-24 12:55:45 +00:00
|
|
|
module.exports = Bob;
|