2017-08-15 23:38:35 +01:00
|
|
|
|
|
|
|
var Class = require('../../utils/Class');
|
|
|
|
var Components = require('./Components');
|
|
|
|
var Image = require('../../gameobjects/image/Image');
|
|
|
|
|
|
|
|
var ImpactImage = new Class({
|
|
|
|
|
|
|
|
Extends: Image,
|
|
|
|
|
|
|
|
Mixins: [
|
|
|
|
Components.Acceleration,
|
2017-08-17 06:00:38 +01:00
|
|
|
Components.BodyScale,
|
2017-08-15 23:38:35 +01:00
|
|
|
Components.BodyType,
|
|
|
|
Components.Bounce,
|
|
|
|
Components.CheckAgainst,
|
|
|
|
Components.Collides,
|
2017-08-16 19:31:59 +01:00
|
|
|
Components.Debug,
|
2017-08-17 03:48:39 +01:00
|
|
|
Components.Friction,
|
2017-08-16 00:30:12 +01:00
|
|
|
Components.Gravity,
|
2017-08-16 22:10:43 +01:00
|
|
|
Components.Offset,
|
2017-08-17 01:21:01 +01:00
|
|
|
Components.SetGameObject,
|
2017-08-15 23:38:35 +01:00
|
|
|
Components.Velocity
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-08-16 19:31:59 +01:00
|
|
|
// x/y is the center of the Image / Body, just like other default Game Objects
|
2017-08-15 23:38:35 +01:00
|
|
|
function ImpactImage (world, x, y, texture, frame)
|
|
|
|
{
|
|
|
|
Image.call(this, world.scene, x, y, texture, frame);
|
|
|
|
|
2017-08-16 19:31:59 +01:00
|
|
|
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
|
2017-08-15 23:38:35 +01:00
|
|
|
|
2017-08-17 02:32:08 +01:00
|
|
|
this.body.parent = this;
|
2017-08-15 23:38:35 +01:00
|
|
|
this.body.gameObject = this;
|
|
|
|
|
|
|
|
// Local references to the Body properties
|
2017-08-16 17:27:15 +01:00
|
|
|
this.size = this.body.size;
|
2017-08-16 19:31:59 +01:00
|
|
|
this.offset = this.body.offset;
|
2017-08-15 23:38:35 +01:00
|
|
|
this.vel = this.body.vel;
|
|
|
|
this.accel = this.body.accel;
|
|
|
|
this.friction = this.body.friction;
|
|
|
|
this.maxVel = this.body.maxVel;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = ImpactImage;
|