I’m making a level where a player has to “take a picture” of an object.
I want the overlap to count only if the object you’re taking a picture of is fully within the picture frame.
This beautiful rendition in Paint should explain it better:
I’m currently trying to modify this code to suit my needs. It works, but it still recognises partial overlap as viable, which is what I want to exclude. Basically, I don’t want “touching” or “partial overlap” to count as overlapping.
update() {
this.astros.getChildren().forEach(astro =>{
// Treat 'embedded' as 'touching' also
if (astro.body.embedded) {
astro.body.touching.none = false
};
var touching = !astro.body.touching.none;
var wasTouching = !astro.body.wasTouching.none;
if (touching && !wasTouching) {
astro.emit("overlapstart");
console.log("overlap start");
}
else if (!touching && wasTouching) {
astro.emit("overlapend");
console.log("overlap end");
}
});
}
Any help would be greatly appreciated