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+ ...
随机推荐
- Log Sessions to Local Database
Add Rules to Fiddler to create a new menu item as follows: // Log the currently selected sessions in ...
- navicat 使用
sql是操作数据库中数据的语句,在不同的数据库中会略有不同,如mysql,postgreSQL,oracle,sqlserver,sqlite等等,但是sql的基础select.insert.upda ...
- 修改ligerui 默认确认按钮
$.extend($.ligerDefaults.DialogString, {ok: '取消单据'}); showDialogPay = $.ligerDialog.alert('正在支付中,请稍候 ...
- OpenERP在product中增加外部网络链接图片
最近的一个项目要求在Product_Template中增加类似与HTML中<img src=”" />的形式的图片 product_img_extra.py from osv i ...
- 【转】Asp.Net MVC4 之Url路由
MVC4常见路由的处理方式 //直接方法重载+匿名对象 routes.MapRoute( name: "Default", url: "{controller}/{act ...
- Codeforces554C:Kyoya and Colored Balls(组合数学+费马小定理)
Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are ...
- servlet Servlet例子
Servlet是sun公司提供的一门用于开发动态web资源的技术. Sun公司在其API中提供了一个servlet接口(参看J2EE API文档),用户若想使用Java程序开发一个动态web资源, ...
- Tomcat訪问日志浅析
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" ...
- mysql优化不可不做的事情
写在前面的话:总是在灾难发生后,才想起容灾的重要性:总是在吃过亏后,才记得有人提醒过 设计原则 1.不在数据库做运算:cpu计算务必移至业务层 2.控制单表数据量:单表记录控制在1000w 3.控制列 ...
- PLSQL_Oracle Exception异常分类、异常抛出、异常处理、异常传播(概念)
2014-06-03 Created By BaoXinjian