e1 属性 y を 1 またはその他の正の値に変更すると、このコードは機能しますが、y が 0 または負の場合は失敗します。エラーはありませんが、形状が表示されません。他の種類の図形を描画すると、同じ種類の問題が発生します。いずれにせよ、0、90、271 などの回転値は y:0 で動作します。x 値ではそのような問題はありません。何故ですか?Crafty.js に関連するバグですか?
<script>
Crafty.init(480,680, document.getElementById('test'));
Crafty.c("myComponent", {
init: function () {
this.requires("2D, Canvas");
this.bind("Draw", this._draw_me);
this.ready = true;
},
_draw_me: function (e) {
var ctx = e.ctx;
ctx.beginPath();
ctx.moveTo(e.pos._x, e.pos._y);
ctx.lineTo(e.pos._x + e.pos._w, e.pos._y);
ctx.lineTo(e.pos._x + e.pos._w/2, e.pos._y + e.pos._h);
ctx.lineTo(e.pos._x, e.pos._y);
ctx.fillStyle = "blue";
ctx.fill();
}
});
var e1 = Crafty.e("myComponent")
.attr({x: 100, y: 0, w: 60, h: 60, rotation:180})
.origin("center");
</script>