Cocos2d-x  v3.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
cocos2d::DrawPrimitives Namespace Reference

IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! More...

Functions

void init ()
 Initializes the drawing primitives.
 
void free ()
 Frees allocated resources by the drawing primitives.
 
void drawPoint (const Vec2 &point)
 Draws a point given x and y coordinate measured in points. More...
 
local drawPoint ( local point)
 Draws a point given x and y coordinate measured in points. More...
 
void drawPoints (const Vec2 *points, unsigned int numberOfPoints)
 Draws an array of points. More...
 
local drawPoints ( local points, local numberOfPoints)
 Draws an array of points. More...
 
void drawLine (const Vec2 &origin, const Vec2 &destination)
 Draws a line given the origin and destination point measured in points. More...
 
void drawRect (Vec2 origin, Vec2 destination)
 Draws a rectangle given the origin and destination point measured in points. More...
 
void drawSolidRect (Vec2 origin, Vec2 destination, Color4F color)
 Draws a solid rectangle given the origin and destination point measured in points. More...
 
local drawSolidRect ( local origin, local destination, local color)
 Draws a solid rectangle given the origin and destination point measured in points. More...
 
void drawPoly (const Vec2 *vertices, unsigned int numOfVertices, bool closePolygon)
 Draws a polygon given a pointer to point coordinates and the number of vertices measured in points. More...
 
void drawSolidPoly (const Vec2 *poli, unsigned int numberOfPoints, Color4F color)
 Draws a solid polygon given a pointer to Vec2 coordinates, the number of vertices measured in points, and a color. More...
 
void drawCircle (const Vec2 &center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY)
 Draws a circle given the center, radius and number of segments. More...
 
void drawCircle (const Vec2 &center, float radius, float angle, unsigned int segments, bool drawLineToCenter)
 Draws a circle given the center, radius and number of segments. More...
 
local drawCircle ( local center, local radius, local angle, local segments, local drawLineToCenter)
 Draws a circle given the center, radius and number of segments. More...
 
void drawSolidCircle (const Vec2 &center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
 Draws a solid circle given the center, radius and number of segments. More...
 
void drawSolidCircle (const Vec2 &center, float radius, float angle, unsigned int segments)
 Draws a solid circle given the center, radius and number of segments. More...
 
void drawQuadBezier (const Vec2 &origin, const Vec2 &control, const Vec2 &destination, unsigned int segments)
 Draws a quad bezier path. More...
 
local drawQuadBezier ( local origin, local control, local destination, local segments)
 Draws a quad bezier path. More...
 
void drawCubicBezier (const Vec2 &origin, const Vec2 &control1, const Vec2 &control2, const Vec2 &destination, unsigned int segments)
 Draws a cubic bezier path. More...
 
local drawCubicBezier ( local origin, local control1, local control2, local destination, local segments)
 Draws a cubic bezier path. More...
 
void drawCatmullRom (PointArray *arrayOfControlPoints, unsigned int segments)
 Draws a Catmull Rom path. More...
 
void drawCardinalSpline (PointArray *config, float tension, unsigned int segments)
 Draws a Cardinal Spline path. More...
 
local drawCardinalSpline ( local config, local tension, local segments)
 Draws a Cardinal Spline path. More...
 
void setDrawColor4B (GLubyte r, GLubyte g, GLubyte b, GLubyte a)
 Set the drawing color with 4 unsigned bytes. More...
 
void setDrawColor4F (GLfloat r, GLfloat g, GLfloat b, GLfloat a)
 Set the drawing color with 4 floats. More...
 
void setPointSize (GLfloat pointSize)
 Set the point size in points. More...
 

Detailed Description

IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT!

LEGACY FUNCTIONS

USE DrawNode instead

Drawing OpenGL ES primitives.

  • drawPoint, drawPoints
  • drawLine
  • drawRect, drawSolidRect
  • drawPoly, drawSolidPoly
  • drawCircle
  • drawQuadBezier
  • drawCubicBezier
  • drawCatmullRom
  • drawCardinalSpline

You can change the color, point size, width by calling:

  • drawColor4B(), drawColor4F()
  • ccPointSize()
  • glLineWidth()

These functions draws the Line, Vec2, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch. Instead you should use DrawNode

Function Documentation

void
cocos2d::DrawPrimitives::drawPoint
( const Vec2 &  point)

Draws a point given x and y coordinate measured in points.

A Vec2 with a point given x and y coordinate.

var drawPoint ( var  point)

Draws a point given x and y coordinate measured in points.

A Vec2 with a point given x and y coordinate.

local drawPoint ( local  point)

Draws a point given x and y coordinate measured in points.

A Vec2 with a point given x and y coordinate.

void
cocos2d::DrawPrimitives::drawPoints
( const Vec2 *  points,
unsigned int  numberOfPoints 
)

Draws an array of points.

A point coordinates. The number of points.

var drawPoints ( var  points,
var  numberOfPoints 
)

Draws an array of points.

A point coordinates. The number of points.

local drawPoints ( local  points,
local  numberOfPoints 
)

Draws an array of points.

A point coordinates. The number of points.

void
cocos2d::DrawPrimitives::drawLine
( const Vec2 &  origin,
const Vec2 &  destination 
)

Draws a line given the origin and destination point measured in points.

A Vec2 Type point used to the line origin. A Vec2 Type point used to the line destination.

var drawLine ( var  origin,
var  destination 
)

Draws a line given the origin and destination point measured in points.

A Vec2 Type point used to the line origin. A Vec2 Type point used to the line destination.

local drawLine ( local  origin,
local  destination 
)

Draws a line given the origin and destination point measured in points.

A Vec2 Type point used to the line origin. A Vec2 Type point used to the line destination.

void
cocos2d::DrawPrimitives::drawRect
( Vec2  origin,
Vec2  destination 
)

Draws a rectangle given the origin and destination point measured in points.

The origin and the destination can not have the same x and y coordinate.

The rectangle origin. The rectangle destination.

var drawRect ( var  origin,
var  destination 
)

Draws a rectangle given the origin and destination point measured in points.

The origin and the destination can not have the same x and y coordinate.

The rectangle origin. The rectangle destination.

local drawRect ( local  origin,
local  destination 
)

Draws a rectangle given the origin and destination point measured in points.

The origin and the destination can not have the same x and y coordinate.

The rectangle origin. The rectangle destination.

void
cocos2d::DrawPrimitives::drawSolidRect
( Vec2  origin,
Vec2  destination,
Color4F  color 
)

Draws a solid rectangle given the origin and destination point measured in points.

The origin and the destination can not have the same x and y coordinate.

The rectangle origin. The rectangle destination. The rectangle color.

var drawSolidRect ( var  origin,
var  destination,
var  color 
)

Draws a solid rectangle given the origin and destination point measured in points.

The origin and the destination can not have the same x and y coordinate.

The rectangle origin. The rectangle destination. The rectangle color.

local drawSolidRect ( local  origin,
local  destination,
local  color 
)

Draws a solid rectangle given the origin and destination point measured in points.

The origin and the destination can not have the same x and y coordinate.

The rectangle origin. The rectangle destination. The rectangle color.

void
cocos2d::DrawPrimitives::drawPoly
( const Vec2 *  vertices,
unsigned int  numOfVertices,
bool  closePolygon 
)

Draws a polygon given a pointer to point coordinates and the number of vertices measured in points.

The polygon can be closed or open.

A pointer to point coordinates. The number of vertices measured in points. The polygon can be closed or open.

var drawPoly ( var  vertices,
var  numOfVertices,
var  closePolygon 
)

Draws a polygon given a pointer to point coordinates and the number of vertices measured in points.

The polygon can be closed or open.

A pointer to point coordinates. The number of vertices measured in points. The polygon can be closed or open.

local drawPoly ( local  vertices,
local  numOfVertices,
local  closePolygon 
)

Draws a polygon given a pointer to point coordinates and the number of vertices measured in points.

The polygon can be closed or open.

A pointer to point coordinates. The number of vertices measured in points. The polygon can be closed or open.

void
cocos2d::DrawPrimitives::drawSolidPoly
( const Vec2 *  poli,
unsigned int  numberOfPoints,
Color4F  color 
)

Draws a solid polygon given a pointer to Vec2 coordinates, the number of vertices measured in points, and a color.

A solid polygon given a pointer to Vec2 coordinates. The number of vertices measured in points. The solid polygon color.

var drawSolidPoly ( var  poli,
var  numberOfPoints,
var  color 
)

Draws a solid polygon given a pointer to Vec2 coordinates, the number of vertices measured in points, and a color.

A solid polygon given a pointer to Vec2 coordinates. The number of vertices measured in points. The solid polygon color.

local drawSolidPoly ( local  poli,
local  numberOfPoints,
local  color 
)

Draws a solid polygon given a pointer to Vec2 coordinates, the number of vertices measured in points, and a color.

A solid polygon given a pointer to Vec2 coordinates. The number of vertices measured in points. The solid polygon color.

void
cocos2d::DrawPrimitives::drawCircle
( const Vec2 &  center,
float  radius,
float  angle,
unsigned int  segments,
bool  drawLineToCenter,
float  scaleX,
float  scaleY 
)

Draws a circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments. Whether or not draw the line from the origin to center. The scale value in x. The scale value in y.

var drawCircle ( var  center,
var  radius,
var  angle,
var  segments,
var  drawLineToCenter,
var  scaleX,
var  scaleY 
)

Draws a circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments. Whether or not draw the line from the origin to center. The scale value in x. The scale value in y.

local drawCircle ( local  center,
local  radius,
local  angle,
local  segments,
local  drawLineToCenter,
local  scaleX,
local  scaleY 
)

Draws a circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments. Whether or not draw the line from the origin to center. The scale value in x. The scale value in y.

void
cocos2d::DrawPrimitives::drawCircle
( const Vec2 &  center,
float  radius,
float  angle,
unsigned int  segments,
bool  drawLineToCenter 
)

Draws a circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments. Whether or not draw the line from the origin to center.

var drawCircle ( var  center,
var  radius,
var  angle,
var  segments,
var  drawLineToCenter 
)

Draws a circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments. Whether or not draw the line from the origin to center.

local drawCircle ( local  center,
local  radius,
local  angle,
local  segments,
local  drawLineToCenter 
)

Draws a circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments. Whether or not draw the line from the origin to center.

void
cocos2d::DrawPrimitives::drawSolidCircle
( const Vec2 &  center,
float  radius,
float  angle,
unsigned int  segments,
float  scaleX,
float  scaleY 
)

Draws a solid circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments. The scale value in x. The scale value in y.

var drawSolidCircle ( var  center,
var  radius,
var  angle,
var  segments,
var  scaleX,
var  scaleY 
)

Draws a solid circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments. The scale value in x. The scale value in y.

local drawSolidCircle ( local  center,
local  radius,
local  angle,
local  segments,
local  scaleX,
local  scaleY 
)

Draws a solid circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments. The scale value in x. The scale value in y.

void
cocos2d::DrawPrimitives::drawSolidCircle
( const Vec2 &  center,
float  radius,
float  angle,
unsigned int  segments 
)

Draws a solid circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments.

var drawSolidCircle ( var  center,
var  radius,
var  angle,
var  segments 
)

Draws a solid circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments.

local drawSolidCircle ( local  center,
local  radius,
local  angle,
local  segments 
)

Draws a solid circle given the center, radius and number of segments.

The circle center point. The circle rotate of radius. The circle angle. The number of segments.

void
cocos2d::DrawPrimitives::drawQuadBezier
( const Vec2 &  origin,
const Vec2 &  control,
const Vec2 &  destination,
unsigned int  segments 
)

Draws a quad bezier path.

The origin of the bezier path. The control of the bezier path. The destination of the bezier path. The number of segments. This function could be pretty slow. Use it only for debugging purposes.

var drawQuadBezier ( var  origin,
var  control,
var  destination,
var  segments 
)

Draws a quad bezier path.

The origin of the bezier path. The control of the bezier path. The destination of the bezier path. The number of segments. This function could be pretty slow. Use it only for debugging purposes.

local drawQuadBezier ( local  origin,
local  control,
local  destination,
local  segments 
)

Draws a quad bezier path.

The origin of the bezier path. The control of the bezier path. The destination of the bezier path. The number of segments. This function could be pretty slow. Use it only for debugging purposes.

void
cocos2d::DrawPrimitives::drawCubicBezier
( const Vec2 &  origin,
const Vec2 &  control1,
const Vec2 &  control2,
const Vec2 &  destination,
unsigned int  segments 
)

Draws a cubic bezier path.

The origin of the bezier path. The first control of the bezier path. The second control of the bezier path. The destination of the bezier path. The The number of segments. This function could be pretty slow. Use it only for debugging purposes.

var drawCubicBezier ( var  origin,
var  control1,
var  control2,
var  destination,
var  segments 
)

Draws a cubic bezier path.

The origin of the bezier path. The first control of the bezier path. The second control of the bezier path. The destination of the bezier path. The The number of segments. This function could be pretty slow. Use it only for debugging purposes.

local drawCubicBezier ( local  origin,
local  control1,
local  control2,
local  destination,
local  segments 
)

Draws a cubic bezier path.

The origin of the bezier path. The first control of the bezier path. The second control of the bezier path. The destination of the bezier path. The The number of segments. This function could be pretty slow. Use it only for debugging purposes.

void
cocos2d::DrawPrimitives::drawCatmullRom
( PointArray *  arrayOfControlPoints,
unsigned int  segments 
)

Draws a Catmull Rom path.

A point array of control point. The The number of segments. This function could be pretty slow. Use it only for debugging purposes.

var drawCatmullRom ( var  arrayOfControlPoints,
var  segments 
)

Draws a Catmull Rom path.

A point array of control point. The The number of segments. This function could be pretty slow. Use it only for debugging purposes.

local drawCatmullRom ( local  arrayOfControlPoints,
local  segments 
)

Draws a Catmull Rom path.

A point array of control point. The The number of segments. This function could be pretty slow. Use it only for debugging purposes.

void
cocos2d::DrawPrimitives::drawCardinalSpline
( PointArray *  config,
float  tension,
unsigned int  segments 
)

Draws a Cardinal Spline path.

A array point. The tension of the spline. The The number of segments. This function could be pretty slow. Use it only for debugging purposes.

var drawCardinalSpline ( var  config,
var  tension,
var  segments 
)

Draws a Cardinal Spline path.

A array point. The tension of the spline. The The number of segments. This function could be pretty slow. Use it only for debugging purposes.

local drawCardinalSpline ( local  config,
local  tension,
local  segments 
)

Draws a Cardinal Spline path.

A array point. The tension of the spline. The The number of segments. This function could be pretty slow. Use it only for debugging purposes.

void
cocos2d::DrawPrimitives::setDrawColor4B
( GLubyte  r,
GLubyte  g,
GLubyte  b,
GLubyte  a 
)

Set the drawing color with 4 unsigned bytes.

The red color with a unsigned bytes. The green color with a unsigned bytes. The blue color with a unsigned bytes. Alpha with a unsigned bytes.

var setDrawColor4B ( var  r,
var  g,
var  b,
var  a 
)

Set the drawing color with 4 unsigned bytes.

The red color with a unsigned bytes. The green color with a unsigned bytes. The blue color with a unsigned bytes. Alpha with a unsigned bytes.

local setDrawColor4B ( local  r,
local  g,
local  b,
local  a 
)

Set the drawing color with 4 unsigned bytes.

The red color with a unsigned bytes. The green color with a unsigned bytes. The blue color with a unsigned bytes. Alpha with a unsigned bytes.

void
cocos2d::DrawPrimitives::setDrawColor4F
( GLfloat  r,
GLfloat  g,
GLfloat  b,
GLfloat  a 
)

Set the drawing color with 4 floats.

The red color with an floats. The green color with an floats. The blue color with an floats. Alpha with an floats.

var setDrawColor4F ( var  r,
var  g,
var  b,
var  a 
)

Set the drawing color with 4 floats.

The red color with an floats. The green color with an floats. The blue color with an floats. Alpha with an floats.

local setDrawColor4F ( local  r,
local  g,
local  b,
local  a 
)

Set the drawing color with 4 floats.

The red color with an floats. The green color with an floats. The blue color with an floats. Alpha with an floats.

void
cocos2d::DrawPrimitives::setPointSize
( GLfloat  pointSize)

Set the point size in points.

Default 1.

The point size with an float.

var setPointSize ( var  pointSize)

Set the point size in points.

Default 1.

The point size with an float.

local setPointSize ( local  pointSize)

Set the point size in points.

Default 1.

The point size with an float.