Cocos2d-JS cc.DrawNode 사용법

3993 단어
app.js
var HelloWorldLayer = cc.Layer.extend({
    sprite:null,
    ctor:function () {
        //////////////////////////////
        // 1. super init first
        this._super();
        // 
        

        return true;
    }
});

var HelloWorldScene = cc.Scene.extend({
    onEnter:function () {
        this._super();
        var layer = new HelloWorldLayer();
        this.addChild(layer);
    }
});

 
 
직사각형 그리기:drawRect
        // draw 
        var drawNode =new cc.DrawNode();
        // , : , , , , 
        drawNode.drawRect(cc.p(0,0),cc.p(300,300),cc.color(),5,cc.color(255,255,0,255));
        // Layer  
        this.addChild(drawNode);

 
도트 그리기:drawDot
        // draw 
        var drawNode =new cc.DrawNode();
        // , : , ,  
        drawNode.drawDot(cc.p(100,100),10,cc.color(255,255,255));
        // Layer  
        this.addChild(drawNode);

 
원형 그리기:drawCircle
        // draw 
        var drawNode =new cc.DrawNode();
        // , : , , , ( ), , , 
        drawNode.drawCircle(cc.p(200, 200), 50, 0, 50, false, 2, cc.color(0, 255, 0, 255));
        // Layer  
        this.addChild(drawNode);

 
다각형 그리기:drawPoly
        // draw 
        var drawNode =new cc.DrawNode();
       // 
        var vertices = [cc.p(60, 80), cc.p(60, 230), cc.p(500, 80)];
        // , : , , , 
        drawNode.drawPoly(vertices, cc.color(0, 255, 255, 80), 2, cc.color(255, 0, 0, 255));
        // Layer  
        this.addChild(drawNode);

 
선 그리기:drawSegment
        // draw 
        var drawNode =new cc.DrawNode();
        // , : , , , 
        drawNode.drawSegment(cc.p(0, 0), cc.p(200,300), 1, cc.color(255, 0, 255, 255));
        // Layer  
        this.addChild(drawNode);

 
곡선 그리기:drawCardinal Spline
        // draw 
        var drawNode =new cc.DrawNode();
        var vertices = [cc.p(60, 80), cc.p(60, 300), cc.p(300, 60)];
        // , : , , , , 
        drawNode.drawCardinalSpline(vertices, 0.5,4,2,cc.color(255, 255, 255, 255));
        // Layer  
        this.addChild(drawNode);
        

 
 
좌표 이동:node.setPosition
        drawNode.setPositionX(22);
        drawNode.setPositionY(22);

좋은 웹페이지 즐겨찾기