#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. php json数据处理中文编码

    <?php function Notice(){ include './include/conn.php'; //数据库链接文件 $sql_notice = mysql_query('SELEC ...

  2. 【设计模式】学习笔记15:代理模式(Proxy Pattern)

    本文出自   http://blog.csdn.net/shuangde800 本笔记内容: 1. JAVA远程代理调用(RMI) 2. 代理模式 走进代理模式 在上一篇的状态模式中,我们实现了一个糖 ...

  3. Idea Spring-boot gradle lombok

    1:build.gradle compile("org.projectlombok:lombok:1.16.16") 2:idea安装lombok插件 3:设置 4:重启

  4. 2019年所有人必须要掌握的一个技能 - “AI思维”

    或许很多人认为AI只是那些直接从事AI相关岗位的人必须要掌握的技能,但实际上,不分岗位所有人都需要一种能力,那就是“AI思维”.如果没能在合适的时机把自己的认知提升到一定程度,被替代是很自然的事情.在 ...

  5. Qt音乐播放器制作(一)Easy Player

    前几天忽然间认为,事到现在Qt的功底也有些基础了,为什么不试着自己做个玩意来玩玩呢?刚好在开源中国逛代码区的时候看到一个QKugou的项目,就想着做一个在线音乐播放器好了. 于是開始着手准备,忙活了一 ...

  6. logging日志管理--将日志打印在屏幕上

    # -*- coding: cp936 -*- # test.py #http://blog.chinaunix.net/uid-27571599-id-3492860.html #logging日志 ...

  7. CAS 5.1.x 的搭建和使用(一)—— 通过Overlay搭建服务端

    CAS单点登录系列: CAS 5.1.x 的搭建和使用(一)—— 通过Overlay搭建服务端 CAS5.1.x 的搭建和使用(二)—— 通过Overlay搭建服务端-其它配置说明 CAS5.1.x ...

  8. hosts.allow hosts.deny

    简单控制访问ip,hosts.allow/hsots.deny  a simple access control language that is based on client (host name ...

  9. 修改apache配置文件去除thinkphp url中的index.php(转)

    例如你的原路径是 http://localhost/test/index.php/index/add那么现在的地址是 http://localhost/test/index/add如何去掉index. ...

  10. 解决LLDB模式下出现message sent to deallocated instance错误

    本文在源文的基础上做整理:http://www.devdiv.com/home.php?mod=space&uid=50901&do=blog&id=50856 Xcode版本 ...