I'm very open to critique. Can you elaborate?
Repeating strings is hard to refactor and comparing strings is much less efficient than comparing integers. Think about making sure every bit in two 2 * 8 * length string of bits plus overhead is the same vs two 32bit integers. The latter far fewer cycles.
var firstTouchBehaviour = {
touchCount: 0,
events: {
firstTouch: 'FirstTouch'
},
setup: function(owner) {
andro.eventer(owner).bind(this, "touch", function(contact) {
if(contact === "added") {
if(this.touchCount === 0) {
andro.eventer(owner).emit(this.events.firstTouch);
}
this.touchCount++;
} else if(contact === "removed") {
this.touchCount--;
}
});
}
};
and var soundBehaviour = {
setup: function(owner) {
andro.eventer(owner).bind(this, firstTouchBehaviour.events.firstTouch , function() {
console.log("Rarrrrrwwwwwwwwwwwwwwww");
});
}
};