I am a complete novice in createjs and wanted some guidance over this topic of collision detection. I have created some text objects using font awesome using a loop. Next I saved them in variable objx
as id
along with updating its position coordinates(x,y)
in it. And here is the code for collision detection:
createjs.Ticker.addEventListener("tick", function(){
var jx,jy,jt,t;
for(var i = 0 ; i < objx.length-1 ; i++)objx[i].id.color="#8B0000";
for(var i = 0 ; i < objx.length-1 ; i++){
x = objx[i].x;y = objx[i].y;t = objx[i].id;
for(var j = i+1 ; j < objx.length-1 ; j++){
jx = objx[j].x;jy = objx[j].y;
if(x+t.getMeasuredWidth()>=jx && y+t.getMeasuredHeight()>=jy )
{
jt = objx[j].id;
jt.color="#0000CD";
t.color="#0000CD";
}
}
}
stage.update();});
}
}
The initial part of tweenjs is working fine. I just wanted the collision to occur in such a way such that color of text changes only on collision and should be back to initial color after collision. This generates an image which is similar to :