#ifndef _DRAW_PRIMITIVES_TEST_H_
#define _DRAW_PRIMITIVES_TEST_H_ ////----#include "cocos2d.h"
#include "../testBasic.h" class DrawPrimitivesTest : public CCLayer
{
public:
DrawPrimitivesTest();
virtual void draw();//必须重写这个函数,画图要在这函数中画
}; class DrawPrimitivesTestScene : public TestScene
{
public:
virtual void runThisTest();
}; #endif
void DrawPrimitivesTest::draw()
{
CHECK_GL_ERROR_DEBUG(); // draw a simple line
// The default state is:
// Line Width: 1
// color: 255,255,255,255 (white, non-transparent)
// Anti-Aliased
// glEnable(GL_LINE_SMOOTH);
ccDrawLine( VisibleRect::leftBottom(), VisibleRect::rightTop() );//画线 CHECK_GL_ERROR_DEBUG(); // line: color, width, aliased
// glLineWidth > 1 and GL_LINE_SMOOTH are not compatible
// GL_SMOOTH_LINE_WIDTH_RANGE = (1,1) on iPhone
// glDisable(GL_LINE_SMOOTH);
glLineWidth( 5.0f );//设置线宽
ccDrawColor4B(,,,);//设置线的颜色
ccDrawLine( VisibleRect::leftTop(), VisibleRect::rightBottom() ); CHECK_GL_ERROR_DEBUG(); // TIP:
// If you are going to use always the same color or width, you don't
// need to call it before every draw
//
// Remember: OpenGL is a state-machine. // draw big point in the center
ccPointSize();//设置点的大小
ccDrawColor4B(,,,);
ccDrawPoint( VisibleRect::center() );//画点 CHECK_GL_ERROR_DEBUG(); // draw 4 small points
CCPoint points[] = { ccp(,), ccp(,), ccp(,), ccp(,) };
ccPointSize();
ccDrawColor4B(,,,);
ccDrawPoints( points, );//画4个点 CHECK_GL_ERROR_DEBUG(); // draw a green circle with 10 segments
glLineWidth();
ccDrawColor4B(, , , );
ccDrawCircle( VisibleRect::center(), , , , false);//画圆 CHECK_GL_ERROR_DEBUG(); // draw a green circle with 50 segments with line to center
glLineWidth();
ccDrawColor4B(, , , );
ccDrawCircle( VisibleRect::center(), , CC_DEGREES_TO_RADIANS(), , true);//第一个参数:圆点,第二个参数:半径,第三个参数:角度,第四个参数:,第五个参数:是否填充 CHECK_GL_ERROR_DEBUG(); // open yellow poly
ccDrawColor4B(, , , );
glLineWidth();
CCPoint vertices[] = { ccp(,), ccp(,), ccp(,), ccp(,), ccp(,) };
ccDrawPoly( vertices, , false);//画线段,false表示不封闭 CHECK_GL_ERROR_DEBUG(); // filled poly
glLineWidth();
CCPoint filledVertices[] = { ccp(,), ccp(,), ccp(,), ccp(,), ccp(,) };
ccDrawSolidPoly(filledVertices, , ccc4f(0.5f, 0.5f, , ) );//对点集所围成的范围填充相应颜色 // closed purble poly
ccDrawColor4B(, , , );
glLineWidth();
CCPoint vertices2[] = { ccp(,), ccp(,), ccp(,) };
ccDrawPoly( vertices2, , true);//画线段,并且收尾两点要封闭 CHECK_GL_ERROR_DEBUG(); // draw quad bezier path
ccDrawQuadBezier(VisibleRect::leftTop(), VisibleRect::center(), VisibleRect::rightTop(), );//画贝塞尔曲线 CHECK_GL_ERROR_DEBUG(); // draw cubic bezier path
ccDrawCubicBezier(VisibleRect::center(), ccp(VisibleRect::center().x+,VisibleRect::center().y+), ccp(VisibleRect::center().x+,VisibleRect::center().y-),VisibleRect::right(),); CHECK_GL_ERROR_DEBUG(); //draw a solid polygon
CCPoint vertices3[] = {ccp(,), ccp(,), ccp(,), ccp(,)};
ccDrawSolidPoly( vertices3, , ccc4f(,,,) );//4条线段,并填充相应颜色 // restore original values
glLineWidth();
ccDrawColor4B(,,,);
ccPointSize(); CHECK_GL_ERROR_DEBUG();
}

DrawPrimitivesTest的更多相关文章

  1. Cocos2d-x3.3它DrawPrimitivesTest分析

    1.代码列表 2.VisibleRect类 该类是test-cpp自带工具类 3.HelloWorldScene类 同前面代码 4.DrawPrimitivesDemo类 1).h文件 #includ ...

  2. quick-cocos2d-x之testlua之mainMenu.lua

    require "helper" require "testResource" require "ActionsTest.ActionsTest&qu ...

  3. cocos2d-x 绘制基本图元

    转自:http://4137613.blog.51cto.com/4127613/754729 第一部分:基本图形绘制   cocos2dx封装了大量opengl函数,用于快速绘制基本图形,这些代码的 ...

  4. 【转】cocos2d-x学习笔记03:绘制基本图元

    第一部分:基本图形绘制 cocos2dx封装了大量opengl函数,用于快速绘制基本图形,这些代码的例子在,tests\DrawPrimitivesTest目录下 注意,该方法是重载node的draw ...

  5. 解说cocos2d-x几种画图方法的用法与思考

    CCRenderTexture 自己的理解 CCRenderTexture类似一张空白的“画布“,用户通过自定义笔刷(CCSprite*),在touch事件中把笔刷的移动痕迹“记录”起来,从而“画”出 ...

  6. 按 Eclipse 开发喜好重新布置 cocos2dx 目录层次

    [tonyfield 2013.08.29 ] 1.  Cocos2dx 库的改动 处于个人的固执,花一天时间重新布置了cocos2dx 2.1.4的目录层次,将android平台无关的代码全数裁剪, ...

  7. Cocos2d-x 3.1.1 lua-tests 开篇

    Cocos2d-x 3.1.1 lua-tests开篇   本篇博客打算从研究Cocos2d-x引擎提供的測试样例来写起,笔者针对Cocos2d-x 3.1.1这个版本号来介绍怎样来学习它给我们提供的 ...

  8. Cocos2d-x绘制圆角矩形

    /* * @brief 画圆角矩形 * @param origin 矩形开始点 * @param destination 矩形结束点 * @param radius 圆角半径 * @param seg ...

  9. 用vs2012编译cocos2dx-3.9

    这几天想玩一下cocos2dx3.9新版本的东西,但是公司电脑配置不够,开个vs2012都卡的不行,更别提高版本的了.因为cocos2dx-3.9中使用了好多c++11的规范,而vs2012有好多C+ ...

随机推荐

  1. 带"叉叉"的GridView

    由于需要用到“删除图片”的功能,需要写这样一个小demo: 对之前博文的修改 发现imageView监听点击事件 效果实在不敢恭维,因此换个方式:设置Touch的监听函数, 下面的Demo没有改过来哈 ...

  2. vb sendmessage 详解1

    SendMessage函数的常用消息及其应用(有点长,希望能对大家有所帮助)函数原型: Declare Function SendMessage Lib "user32" Alia ...

  3. Android自动填写获取到的验证码

    Android需要添加的相关权限 <uses-permission android:name="android.permission.RECEIVE_SMS">< ...

  4. mac安装热更新插件

    查看.修改或者执行某些命令需要root用户的权限,如果不想直接切换到root用户,就可以使用sudo命令.sudo命令用于针对单个命令授予临时权限.sudo仅在需要时授予用户权限,减少了用户因为错误执 ...

  5. shell脚本中的几个括号总结(小括号/大括号/花括号)

    from:http://www.cnblogs.com/hanyan225/archive/2011/10/06/2199652.html 是毋庸置疑的,方便了我们也迷惑了我们,比如这些杂七杂八的括号 ...

  6. openerp用wizard导入excel数据

    来自:http://blog.csdn.net/yumingbuzhongyao/article/details/18669183 作为一个quick note吧. OE里的csv导入数据功能形同摆设 ...

  7. 〖Linux〗Qt+gsoap开发客户端程序,服务端地址设定的字符串转换处理

    之所以写出来,是由于经常因为这个问题屡屡丢面子.. 一般情况下,QString转换成(char*),我们一般直接使用: char *str = qstr->text().toLatin1().d ...

  8. fread与read的差别(文件io补充)

    这里有一个我们常常提出的问题就是fread,read的差别.(当然这两个分别代表了操作文件系统的两套不同的函数,包含open,read, write, seek 等). 一.他们的差别就是一个(rea ...

  9. DX:神奇的LayoutControl.BestFit()

    自动生成LayoutControl后,界面总是不对:在LayoutControl中找到一个BestFit()方法,调用后神奇的结果出现了,这不正是我想要的吗?测试代码: public partial ...

  10. phpCAS library

    The phpCAS library provides a simple API for authenticating users against a CAS server. phpCAS is co ...