Cocos Creator API

1.3.0

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

CollisionManager

: cc

A simple collision manager class. It will calculate whether the collider collides other colliders, if collides then call the callbacks.

:

// Get the collision manager.
var manager = cc.director.getCollisionManager();

// Enabled the colider manager.
manager.enabled = true;

// Enabled draw collider
manager.enabledDebugDraw = true;

// Enabled draw collider bounding box
manager.enabledDrawBoundingBox = true;


// Collision callback
onCollisionEnter: function (other, self) {
    this.node.color = cc.Color.RED;
    this.touchingNumber ++;

    // var world = self.world;
    // var aabb = world.aabb;
    // var preAabb = world.preAabb;
    // var t = world.transform;

    // for circle collider
    // var r = world.radius;
    // var p = world.position;

    // for box collider and polygon collider
    // var ps = world.points;
},

onCollisionStay: function (other, self) {
    console.log('on collision stay');
},

onCollisionExit: function (other, self) {
    this.touchingNumber --;
    if (this.touchingNumber === 0) {
        this.node.color = cc.Color.WHITE;
    }
}
});

enabled Boolean

enabledDrawBoundingBox Boolean

enabledDebugDraw Boolean

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index