DrawPrimitivesTest
#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的更多相关文章
- Cocos2d-x3.3它DrawPrimitivesTest分析
1.代码列表 2.VisibleRect类 该类是test-cpp自带工具类 3.HelloWorldScene类 同前面代码 4.DrawPrimitivesDemo类 1).h文件 #includ ...
- quick-cocos2d-x之testlua之mainMenu.lua
require "helper" require "testResource" require "ActionsTest.ActionsTest&qu ...
- cocos2d-x 绘制基本图元
转自:http://4137613.blog.51cto.com/4127613/754729 第一部分:基本图形绘制 cocos2dx封装了大量opengl函数,用于快速绘制基本图形,这些代码的 ...
- 【转】cocos2d-x学习笔记03:绘制基本图元
第一部分:基本图形绘制 cocos2dx封装了大量opengl函数,用于快速绘制基本图形,这些代码的例子在,tests\DrawPrimitivesTest目录下 注意,该方法是重载node的draw ...
- 解说cocos2d-x几种画图方法的用法与思考
CCRenderTexture 自己的理解 CCRenderTexture类似一张空白的“画布“,用户通过自定义笔刷(CCSprite*),在touch事件中把笔刷的移动痕迹“记录”起来,从而“画”出 ...
- 按 Eclipse 开发喜好重新布置 cocos2dx 目录层次
[tonyfield 2013.08.29 ] 1. Cocos2dx 库的改动 处于个人的固执,花一天时间重新布置了cocos2dx 2.1.4的目录层次,将android平台无关的代码全数裁剪, ...
- Cocos2d-x 3.1.1 lua-tests 开篇
Cocos2d-x 3.1.1 lua-tests开篇 本篇博客打算从研究Cocos2d-x引擎提供的測试样例来写起,笔者针对Cocos2d-x 3.1.1这个版本号来介绍怎样来学习它给我们提供的 ...
- Cocos2d-x绘制圆角矩形
/* * @brief 画圆角矩形 * @param origin 矩形开始点 * @param destination 矩形结束点 * @param radius 圆角半径 * @param seg ...
- 用vs2012编译cocos2dx-3.9
这几天想玩一下cocos2dx3.9新版本的东西,但是公司电脑配置不够,开个vs2012都卡的不行,更别提高版本的了.因为cocos2dx-3.9中使用了好多c++11的规范,而vs2012有好多C+ ...
随机推荐
- Node FS 读取文件中文乱码解决
1:首先保证源文件编码方式为UTF-8 2:读取代码,设置编码方式rs.setEncoding('utf8') var fs = require('fs'); var rs = fs.createRe ...
- C# 编程实现串口通信
http://blog.sina.com.cn/s/blog_6c67dab30101p3vn.html ----------------------------------------------- ...
- js replace全部替换的方法
1.JS replace()方法替换变量(可以对变量进行全文替换) string.replace(new RegExp(key,'g'),"b"); 2.封装 String.pro ...
- nyoj阶乘之和
/*阶乘之和 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描写叙述 给你一个非负数整数n,推断n是不是一些数(这些数不同意反复使用,且为正数)的阶乘之和, 如9=1! ...
- Circular dependency issuse on cocoapods version(0.36.0) 全然解决方式(非降版本号)
此前的文章中.以前提到在cocoapods依赖管理版本号假设超过0.34.4.比方0.35, 0.36.0等版本号中. 运行"pod install" 或者 "pod u ...
- 如何高效的阅读hadoop源代码?
个人谈谈阅读hadoop源代码的经验. 首先,不得不说,hadoop发展到现在这个阶段,代码已经变得非常庞大臃肿,如果你直接阅读最新版本的源代码,难度比较大,需要足够的耐心和时间,所以,如果你觉得认真 ...
- 深入理解SpringBoot配置
一.application.properties的位置 1.当前目录的 "/config"的子目录下 2.当前目录下 3.classpath根目录的"/config&qu ...
- js访问url和cookie
function QueryString() { var data = []; this.Read = function() { var aPairs, aTmp; var queryString = ...
- SSL原理
http://blog.csdn.net/terryzero/article/details/5921791SSL的原理以前一直很模糊,看了下面这篇文章后清楚了许多,为了方便以后的回顾,所以转载下 R ...
- ajax操作登录
js文件中的内容(ajax.operate.js) ;(function ($, window) { var _ajaxOperate = window.ajaxOperate || {}; _aja ...