Cocos2d-x之绘制线条

Cocos2d-x之绘制线条

自定义的方法

Line.h

  

 1 //
 2 //  Line.h
 3 //  L01DrawingAPI
 4 //
 5 //  Created by Mac OS 10.9.3 on 15-3-30.
 6 //
 7 //
 8 
 9 #ifndef __L01DrawingAPI__Line__
10 #define __L01DrawingAPI__Line__
11 
12 #include 
13 #include 
14 
15 USING_NS_CC;
16 
17 namespace bobo {
18     
19     class Line:public Node{
20         
21     public:
22         
23         virtual bool init();
24         virtual void draw();
25         CREATE_FUNC(Line);
26                 
27     };
28 }
29 
30 #endif /* defined(__L01DrawingAPI__Line__) */

 

 

Line.cpp

 

 1 //
 2 //  Line.cpp
 3 //  L01DrawingAPI
 4 //
 5 //  Created by Mac OS 10.9.3 on 15-3-30.
 6 //
 7 //
 8 
 9 #include "Line.h"
10 
11 namespace bobo {
12     
13     bool Line::init(){
14         
15         return true;
16         
17     }
18     
19     void Line::draw(){
20         
21         DrawPrimitives::drawLine(Point(0, 0), Point(100, 100));
22         
23     }
24 }

 

 

bool HelloWorld::init()

auto l = bobo::Line::create();

    l->setPosition(Point(400, 300));

    addChild(l);

转载于:https://www.cnblogs.com/dudu580231/p/4379556.html

你可能感兴趣的:(游戏,操作系统)