Inherits from NSObject
Declared in PXGraphics.h
PXGraphics.m

Overview

A PXGraphics object represents a way of defining and drawing vector shapes. Both PXSprite and PXShape have PXGraphics objects that can be used for drawing.

IMPORTANT NOTE: This is not the final version of the Graphics class, much more functionality will be added in a later version.

Tasks

  • – beginFill:alpha:

    Begins a fill sequence. Any line, circle, ellipse or rectangle drawn after this call, and before endFill will be filled in with the specified color and alpha.

  • – endFill

    Ends the fill sequence. Any line, circle, ellipse or rectangle drawn after the #beginFill call, and before this call will be filled in with the specified color and alpha.

  • – lineStyleWithThickness:color:alpha:

    Sets the values needed to define a line. Any line, circle, ellipse or rectangle drawn after this call, will have be made up of lines with the specified thickness, color and alpha.

Instance Methods

beginFill:alpha:

Begins a fill sequence. Any line, circle, ellipse or rectangle drawn after this call, and before endFill will be filled in with the specified color and alpha.

- (void)beginFill:(unsigned)color alpha:(float)alpha

Parameters

color

The color for the fill in hex form ranging from 0x000000 for black, and 0xFFFFFF for white.

alpha

The alpha channel for the color ranging between 0.0f for invisible to 1.0f for full visibility.

Example:

PXShape *shape = [PXShape new];
[shape.graphics beginFill:0xFF0000 alpha:1.0f];
[shape.graphics drawRectWithX:100 y:150 width:64 height:32];
[shape.graphics endFill];
// A red rectangle at (100, 150) with a size of (64, 32) will be drawn to
// the screen, assuming the shape was added to the display list.

See Also

Declared In

PXGraphics.m

endFill

Ends the fill sequence. Any line, circle, ellipse or rectangle drawn after the #beginFill call, and before this call will be filled in with the specified color and alpha.

- (void)endFill

Discussion

Example:

PXShape *shape = [PXShape new];
[shape.graphics beginFill:0xFF0000 alpha:1.0f];
[shape.graphics drawRectWithX:100 y:150 width:64 height:32];
[shape.graphics endFill];
// A red rectangle at (100, 150) with a size of (64, 32) will be drawn to
// the screen, assuming the shape was added to the display list.

See Also

Declared In

PXGraphics.m

lineStyleWithThickness:color:alpha:

Sets the values needed to define a line. Any line, circle, ellipse or rectangle drawn after this call, will have be made up of lines with the specified thickness, color and alpha.

- (void)lineStyleWithThickness:(float)thickness color:(unsigned)color alpha:(float)lineAlpha

Discussion

Example:

PXShape *shape = [PXShape new];
[shape.graphics [lineStyle 0xFF0000] alpha:1.0f];
[shape.graphics drawRectWithX:100 y:150 width:64 height:32];
// A red outline of a rectangle at (100, 150) with a size of (64, 32) will
// be drawn to the screen, assuming the shape was added to the display list.

See Also

Declared In

PXGraphics.m