Answer the question
In order to leave comments, you need to log in
JavaScript. Why doesn't the object collision code work?
self.collision = function () {
if(collisions(this.x, this..y, this.width, this..height)) {
console.log("detected");
}
}
function collisions (rect1, rect2) {
var rect1 = tank;
var rect2 = enemyTank;
return (rect1.x < rect2.x + rect2.width &&
rect1.x + rect1.width > rect2.x &&
rect1.y < rect2.y + rect2.height &&
rect1.height + rect1.y > rect2.y)
}
Answer the question
In order to leave comments, you need to log in
Zashib you posted a footcloth code ... the whole game or something? And we should look in it where it does not work?
I can send you the code where object collision works:
https://jsfiddle.net/bt0qgv9z/1/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question