phaser/v3/src/physics/impact/ImpactImage.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

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