Added all of the Arcade Physics image and sprite components

This commit is contained in:
Richard Davey 2017-11-09 04:02:31 +00:00
parent 5a20ea0de4
commit a84b9d5fcc
11 changed files with 295 additions and 0 deletions

View file

@ -0,0 +1,26 @@
var Acceleration = {
setAcceleration: function (x, y)
{
this.body.acceleration.set(x, y);
return this;
},
setAccelerationX: function (value)
{
this.body.acceleration.x = value;
return this;
},
setAccelerationY: function (value)
{
this.body.acceleration.y = value;
return this;
}
};
module.exports = Acceleration;

View file

@ -0,0 +1,26 @@
var Angular = {
setAngularVelocity: function (value)
{
this.body.angularVelocity = value;
return this;
},
setAngularAcceleration: function (value)
{
this.body.angularAcceleration = value;
return this;
},
setAngularDrag: function (value)
{
this.body.angularDrag = value;
return this;
}
};
module.exports = Angular;

View file

@ -0,0 +1,33 @@
var Bounce = {
setBounce: function (x, y)
{
this.body.bounce.set(x, y);
return this;
},
setBounceX: function (value)
{
this.body.bounce.x = value;
return this;
},
setBounceY: function (value)
{
this.body.bounce.y = value;
return this;
},
setCollideWorldBounds: function (value)
{
this.body.collideWorldBounds = value;
return this;
}
};
module.exports = Bounce;

View file

@ -0,0 +1,63 @@
var Debug = {
setDebug: function (showBody, showVelocity, bodyColor)
{
this.debugShowBody = showBody;
this.debugShowVelocity = showVelocity;
this.debugBodyColor = bodyColor;
return this;
},
setDebugBodyColor: function (value)
{
this.body.debugBodyColor = value;
return this;
},
debugShowBody: {
get: function ()
{
return this.body.debugShowBody;
},
set: function (value)
{
this.body.debugShowBody = value;
}
},
debugShowVelocity: {
get: function ()
{
return this.body.debugShowVelocity;
},
set: function (value)
{
this.body.debugShowVelocity = value;
}
},
debugBodyColor: {
get: function ()
{
return this.body.debugBodyColor;
},
set: function (value)
{
this.body.debugBodyColor = value;
}
}
};
module.exports = Debug;

View file

@ -0,0 +1,26 @@
var Drag = {
setDrag: function (x, y)
{
this.body.drag.set(x, y);
return this;
},
setDragX: function (value)
{
this.body.drag.x = value;
return this;
},
setDragY: function (value)
{
this.body.drag.y = value;
return this;
}
};
module.exports = Drag;

View file

@ -0,0 +1,26 @@
var Friction = {
setFriction: function (x, y)
{
this.body.friction.set(x, y);
return this;
},
setFrictionX: function (x)
{
this.body.friction.x = x;
return this;
},
setFrictionY: function (y)
{
this.body.friction.y = y;
return this;
}
};
module.exports = Friction;

View file

@ -0,0 +1,12 @@
var Immovable = {
setImmovable: function (value)
{
this.body.immovable = value;
return this;
}
};
module.exports = Immovable;

View file

@ -0,0 +1,12 @@
var Mass = {
setMass: function (value)
{
this.body.mass = value;
return this;
}
};
module.exports = Mass;

View file

@ -0,0 +1,19 @@
var Size = {
setSize: function (width, height, offsetX, offsetY)
{
this.body.setSize(width, height, offsetX, offsetY);
return this;
},
setCircle: function (radius, offsetX, offsetY)
{
this.body.setCircle(radius, offsetX, offsetY);
return this;
}
};
module.exports = Size;

View file

@ -0,0 +1,35 @@
var Velocity = {
setVelocity: function (x, y)
{
this.body.velocity.set(x, y);
return this;
},
setVelocityX: function (x)
{
this.body.velocity.x = x;
return this;
},
setVelocityY: function (y)
{
this.body.velocity.y = y;
return this;
},
setMaxVelocity: function (x, y)
{
if (y === undefined) { y = x; }
this.body.maxVelocity.set(x, y);
return this;
}
};
module.exports = Velocity;

View file

@ -0,0 +1,17 @@
// Phaser.Physics.Arcade.Body.Components
module.exports = {
Acceleration: require('./Acceleration'),
Angular: require('./Angular'),
Bounce: require('./Bounce'),
Debug: require('./Debug'),
Drag: require('./Drag'),
Friction: require('./Friction'),
Gravity: require('./Gravity'),
Immovable: require('./Immovable'),
Mass: require('./Mass'),
Size: require('./Size'),
Velocity: require('./Velocity')
};