标签:
自定义的方法
Circle.h
1 // 2 // Circle.h 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-30. 6 // 7 // 8 9 #ifndef __L01DrawingAPI__Circle__ 10 #define __L01DrawingAPI__Circle__ 11 12 #include <iostream> 13 #include <cocos2d.h> 14 15 using namespace cocos2d; 16 17 namespace bobo { 18 19 class Circle:public Node{ 20 21 public: 22 23 virtual bool init(); 24 virtual void draw(); 25 CREATE_FUNC(Circle); 26 27 }; 28 } 29 30 #endif /* defined(__L01DrawingAPI__Circle__) */
Circle.cpp
1 // 2 // Circle.cpp 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-30. 6 // 7 // 8 9 #include "Circle.h" 10 11 namespace bobo { 12 13 bool Circle::init(){ 14 return true; 15 } 16 17 void Circle::draw(){ 18 19 //float scaleX, float scaleY指的是对x,y轴的缩放 20 //DrawPrimitives::drawCircle(const cocos2d::Point ¢er, float radius, 21 // float angle, unsigned int segments, 22 // bool drawLineToCenter, float scaleX, 23 // float scaleY); 24 25 //绘制圆形,(圆心,半径,角度(单位是弧度,现在是360度), 26 //边的个数,是否绘制一条连接到圆心的线) 27 //边的数是几就是正几边型 28 //DrawPrimitives::drawCircle(Point(0, 0), 50, M_PI * 2, 3, true); 29 //DrawPrimitives::drawCircle(Point(0, 0), 50, M_PI * 2, 5, true); 30 DrawPrimitives::drawCircle(Point(0, 0), 50, M_PI * 2, 100, true); 31 } 32 }
在bool HelloWorld::init()中
auto c = bobo::Circle::create();
c->setPosition(Point(400, 100));
addChild(c);
标签:
原文地址:http://www.cnblogs.com/dudu580231/p/4377058.html