cocos2d-iphone  2.1
Improved Cocos2D API Reference (iOS version) for www.kobold2d.com developers
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines
CCDrawingPrimitives.h File Reference
#import <Foundation/Foundation.h>
#import "ccTypes.h"
#import "ccMacros.h"
#import <CoreGraphics/CGGeometry.h>
+ Include dependency graph for CCDrawingPrimitives.h:

Functions

void ccDrawInit (void)
void ccDrawFree (void)
void ccDrawPoint (CGPoint point)
void ccDrawPoints (const CGPoint *points, NSUInteger numberOfPoints)
void ccDrawLine (CGPoint origin, CGPoint destination)
void ccDrawRect (CGPoint origin, CGPoint destination)
void ccDrawSolidRect (CGPoint origin, CGPoint destination, ccColor4F color)
void ccDrawPoly (const CGPoint *vertices, NSUInteger numOfVertices, BOOL closePolygon)
void ccDrawSolidPoly (const CGPoint *poli, NSUInteger numberOfPoints, ccColor4F color)
void ccDrawCircle (CGPoint center, float radius, float angle, NSUInteger segments, BOOL drawLineToCenter)
void ccDrawQuadBezier (CGPoint origin, CGPoint control, CGPoint destination, NSUInteger segments)
void ccDrawCubicBezier (CGPoint origin, CGPoint control1, CGPoint control2, CGPoint destination, NSUInteger segments)
void ccDrawCatmullRom (CCPointArray *arrayOfControlPoints, NSUInteger segments)
void ccDrawCardinalSpline (CCPointArray *config, CGFloat tension, NSUInteger segments)
void ccDrawColor4B (GLubyte r, GLubyte g, GLubyte b, GLubyte a)
void ccDrawColor4F (GLfloat r, GLfloat g, GLfloat b, GLfloat a)
void ccPointSize (GLfloat pointSize)

Detailed Description

Drawing OpenGL ES primitives.

  • ccDrawPoint, ccDrawPoints
  • ccDrawLine
  • ccDrawRect, ccDrawSolidRect
  • ccDrawPoly, ccDrawSolidPoly
  • ccDrawCircle
  • ccDrawQuadBezier
  • ccDrawCubicBezier
  • ccDrawCatmullRom
  • ccDrawCardinalSpline

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

Warning:
These functions draws the Line, Point, 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 CCDrawNode

Function Documentation

void ccDrawCardinalSpline ( CCPointArray config,
CGFloat  tension,
NSUInteger  segments 
)

draws a Cardinal Spline path.

Warning:
This function could be pretty slow. Use it only for debugging purposes.
Since:
v2.0
void ccDrawCatmullRom ( CCPointArray arrayOfControlPoints,
NSUInteger  segments 
)

draws a Catmull Rom path.

Warning:
This function could be pretty slow. Use it only for debugging purposes.
Since:
v2.0
void ccDrawCircle ( CGPoint  center,
float  radius,
float  angle,
NSUInteger  segments,
BOOL  drawLineToCenter 
)

draws a circle given the center, radius and number of segments measured in points

void ccDrawColor4B ( GLubyte  r,
GLubyte  g,
GLubyte  b,
GLubyte  a 
)

set the drawing color with 4 unsigned bytes

Since:
v2.0
void ccDrawColor4F ( GLfloat  r,
GLfloat  g,
GLfloat  b,
GLfloat  a 
)

set the drawing color with 4 floats

Since:
v2.0
void ccDrawCubicBezier ( CGPoint  origin,
CGPoint  control1,
CGPoint  control2,
CGPoint  destination,
NSUInteger  segments 
)

draws a cubic bezier path measured in points.

Warning:
This function could be pretty slow. Use it only for debugging purposes.
Since:
v0.8
void ccDrawFree ( void  )

Frees allocated resources by the drawing primitives

void ccDrawInit ( void  )

Initializes the drawing primitives

void ccDrawLine ( CGPoint  origin,
CGPoint  destination 
)

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

void ccDrawPoint ( CGPoint  point)

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

void ccDrawPoints ( const CGPoint *  points,
NSUInteger  numberOfPoints 
)

draws an array of points.

Since:
v0.7.2
void ccDrawPoly ( const CGPoint *  vertices,
NSUInteger  numOfVertices,
BOOL  closePolygon 
)

draws a polygon given a pointer to CGPoint coordinates and the number of vertices measured in points. The polygon can be closed or open

void ccDrawQuadBezier ( CGPoint  origin,
CGPoint  control,
CGPoint  destination,
NSUInteger  segments 
)

draws a quad bezier path measured in points.

Warning:
This function could be pretty slow. Use it only for debugging purposes.
Since:
v0.8
void ccDrawRect ( CGPoint  origin,
CGPoint  destination 
)

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

void ccDrawSolidPoly ( const CGPoint *  poli,
NSUInteger  numberOfPoints,
ccColor4F  color 
)

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

void ccDrawSolidRect ( CGPoint  origin,
CGPoint  destination,
ccColor4F  color 
)

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

Since:
1.1
void ccPointSize ( GLfloat  pointSize)

set the point size in points. Default 1.

Since:
v2.0