我找不到官方文档的任何暗示,几乎没有。我搜索iphone解决方案,但我在html5中找不到相关的解决方案。我试图创建一个圆形作为精灵,但我不知道如何填充它,有人可以给我任何想法(除了外部图片),请,示例代码非常欢迎。
答案 0 :(得分:1)
以下是示例代码,如下所示:
//------------------------------------------------------------------
//
// Draw New API Test
//
//------------------------------------------------------------------
var DrawNewAPITest = DrawTestDemo.extend({
_title : "cc.DrawNode",
_subtitle : "Testing cc.DrawNode API",
ctor:function() {
this._super();
var draw = cc.DrawNode.create();
this.addChild( draw, 10 );
//
// Circles
//
for( var i=0; i < 10; i++) {
draw.drawDot( cc.p(winSize.width/2, winSize.height/2), 10*(10-i), cc.c4f( Math.random(), Math.random(), Math.random(), 1) );
}
//
// Polygons
//
var points = [ cc.p(winSize.height/4,0), cc.p(winSize.width,winSize.height/5), cc.p(winSize.width/3*2,winSize.height) ];
draw.drawPoly(points, cc.c4f(1,0,0,0.5), 4, cc.c4f(0,0,1,1) );
// star poly (triggers bugs)
var o=80;
var w=20;
var h=50;
var star = [
cc.p(o+w,o-h), cc.p(o+w*2, o), // lower spike
cc.p(o + w*2 + h, o+w ), cc.p(o + w*2, o+w*2), // right spike
cc.p(o +w, o+w*2+h), cc.p(o,o+w*2), // top spike
cc.p(o -h, o+w), cc.p(o,o) // left spike
];
draw.drawPoly(star, cc.c4f(1,0,0,0.5), 1, cc.c4f(0,0,1,1) );
// star poly (doesn't trigger bug... order is important un tesselation is supported.
o=180;
w=20;
h=50;
star = [
cc.p(o,o), cc.p(o+w,o-h), cc.p(o+w*2, o), // lower spike
cc.p(o + w*2 + h, o+w ), cc.p(o + w*2, o+w*2), // right spike
cc.p(o +w, o+w*2+h), cc.p(o,o+w*2), // top spike
cc.p(o -h, o+w) // left spike
];
draw.drawPoly(star, cc.c4f(1,0,0,0.5), 1, cc.c4f(0,0,1,1) );
//
// Segments
//
draw.drawSegment( cc.p(20,winSize.height), cc.p(20,winSize.height/2), 10, cc.c4f(0, 1, 0, 1) );
draw.drawSegment( cc.p(10,winSize.height/2), cc.p(winSize.width/2, winSize.height/2), 40, cc.c4f(1, 0, 1, 0.5) );
}
});
您可以在samples / tests / DrawPrimitivesTest中找到它。