CraftyJS で、プレイヤー エンティティが他のエンティティにクリップするのを防ぐにはどうすればよいですか?
これは私のオブジェクトです:
Crafty.c("Mushroom", {
init: function() {
this.addComponent("collision");
this.collision(new Crafty.polygon([[8,8],[24,8],[24,24],[8,24]]));
}
});
var mushroom = Crafty.e("2D, canvas, mushroomRed, Mushroom")
.attr({x: 200, y: 150, z:1, w: 32, h: 32});
これは私のプレーヤー onHit です:
.onhit("mushroomRed", function() {
this.x += this._speed;
this.stop();
}
特定の角度から近づいた場合にのみ機能します。
アドバイス?