Hello, Bills.
On Wednesday, June 13, 2012 9:26:59 AM UTC-4, Bills wrote:
I'm trying to use Crafty.circle but it not draw on game screen.
I'm currently using the second method, because I didn't want to write all the complex Canvas draw/stroke/fill commands. It's nicer to work with the high-level shape functions. I did a quick Google for Javascript drawing libraries, and found a bunch. I grabbed one that looked like it was in active development --
JsDraw2DX -- and built a Component that looks more or less like this:
// Create circular element
Crafty.c("CircularShape", {
init: function() {
this.requires("2D, DOM");
var strokew = 1;
var pen = new jxPen(new jxColor("white"), strokew);
var brush = new jxBrush(new jxColor("red"));
var center = new jxPoint(this._w / 2, this._h / 2);
var radius = (this._w / 2) - strokew;
var circle = new jxCircle(center, radius, pen, brush);
circle.draw(new jxGraphics(this._element));
return this;
},
});