Game Development Reference
In-Depth Information
Figure 10-12 . The tilemap with object layer rectangles displayed using OpenGL ES code
The -(void) draw method just needs to be in the class, and it will be called auto-
matically every frame. However, you should refrain from using the draw method to
modify properties of nodes because that can interfere with drawing the nodes. Listing
10-5 shows the draw method of the TileMapLayer class.
Listing 10-5 . Drawing ObjectLayer Rectangles
#ifdef DEBUG
-(void) draw
[super draw];
CCNode* node = [self getChildByTag:TileMapNode];
NSAssert([node isKindOfClass:[CCTMXTiledMap class]], @"not a CCTMXTiledMap");
CCTMXTiledMap* tileMap = (CCTMXTiledMap*)node;
// Get the object layer
CCTMXObjectGroup* objectLayer = [tileMap objectGroupNamed:@"ObjectLayer"];
// make the lines thicker
glLineWidth(2.0f * CC_CONTENT_SCALE_FACTOR());
ccDrawColor4F(1, 0, 1, 1);
int numObjects = objectLayer.objects.count;
Search Nedrilad ::

Custom Search