diff --git a/src/entity/entity.js b/src/entity/entity.js
index c1731c8269..8652a214fe 100644
--- a/src/entity/entity.js
+++ b/src/entity/entity.js
@@ -3,14 +3,14 @@ import Renderable from "./../renderable/renderable.js";
import Sprite from "./../renderable/sprite.js";
import Body from "./../physics/body.js";
import Polygon from "./../shapes/poly.js";
-import collision from "./../physics/collision.js";
/**
- * a Generic Object Entity
+ * a Generic Object Entity
* @class
* @extends me.Renderable
* @memberOf me
+ * @see me.Renderable
* @constructor
* @param {Number} x the x coordinates of the entity object
* @param {Number} y the y coordinates of the entity object
@@ -126,19 +126,9 @@ var Entity = Renderable.extend({
this.resize(this.body.getBounds().width, this.body.getBounds().height);
}
- // set the collision mask if defined
- if (typeof(settings.collisionMask) !== "undefined") {
- this.body.setCollisionMask(settings.collisionMask);
- }
-
- // set the collision mask if defined
- if (typeof(settings.collisionType) !== "undefined") {
- if (typeof collision.types[settings.collisionType] !== "undefined") {
- this.body.collisionType = collision.types[settings.collisionType];
- } else {
- throw new Error("Invalid value for the collisionType property");
- }
- }
+ // set the collision mask and type (if defined)
+ this.body.setCollisionMask(settings.collisionMask);
+ this.body.setCollisionType(settings.collisionType);
// disable for entities
this.autoTransform = false;
diff --git a/src/physics/body.js b/src/physics/body.js
index bc632cc7d4..66b4f97c6c 100644
--- a/src/physics/body.js
+++ b/src/physics/body.js
@@ -496,14 +496,14 @@ class Body {
/**
* By default all entities are able to collide with all other entities,
- * but it's also possible to specificy 'collision filters' to provide a finer
+ * but it's also possible to specify 'collision filters' to provide a finer
* control over which entities can collide with each other.
* @name setCollisionMask
* @memberOf me.Body
* @public
* @function
* @see me.collision.types
- * @param {Number} bitmask the collision mask
+ * @param {Number} [bitmask = me.collision.types.ALL_OBJECT] the collision mask
* @example
* // filter collision detection with collision shapes, enemies and collectables
* myEntity.body.setCollisionMask(me.collision.types.WORLD_SHAPE | me.collision.types.ENEMY_OBJECT | me.collision.types.COLLECTABLE_OBJECT);
@@ -511,10 +511,32 @@ class Body {
* // disable collision detection with all other objects
* myEntity.body.setCollisionMask(me.collision.types.NO_OBJECT);
*/
- setCollisionMask(bitmask) {
+ setCollisionMask(bitmask = collision.types.ALL_OBJECT) {
this.collisionMask = bitmask;
}
+ /**
+ * define the collision type of the body for collision filtering
+ * @name setCollisionType
+ * @memberOf me.Body
+ * @public
+ * @function
+ * @see me.collision.types
+ * @param {Number} type the collision type
+ * @example
+ * // set the body collision type
+ * myEntity.body.collisionType = me.collision.types.PLAYER_OBJECT;
+ */
+ setCollisionType(type) {
+ if (typeof type !== "undefined") {
+ if (typeof collision.types[type] !== "undefined") {
+ this.collisionType = collision.types[type];
+ } else {
+ throw new Error("Invalid value for the collisionType property");
+ }
+ }
+ }
+
/**
* the built-in function to solve the collision response
* @protected