Animatron/player — pull request #18 by shamansir (2012-06-19 13:13:45+00:00)
Title: Collisions: Intersections (Bounds)

now `intersects(elm[, t])` test works for bounds-mode, here's the test:

var circleOne = b('c1').circle([0, 0], 30)
.trans([0, 3], [[0, 200], [400, 200]])
.modify(function(t) {
var isects = this.$.intersects(circleTwo.v);
if (isects) console.log(t, 'circle one intersects circle two');
circleOne.fill(isects ? '#0f0' : '#ccc');
});
var circleTwo = b('c2').circle([0, 0], 50)
.trans([0, 3], [[400, 200], [0, 200]])
.modify(function(t) {
var isects = this.$.intersects(circleOne.v);
if (isects) console.log(t, 'circle two intersects circle one');
circleTwo.fill(isects ? '#f00' : '#ccc');
});

return b().add(circleOne).add(circleTwo);

Additions:

* fix incorrect bounds-checks
* fix not resetting scene when calling drawAt
* fix checking contains/intersects with not-initialized state