Dibujamos una cuadricula de tamaño kTileSize definido como constante en el .h.
- (void)draw
{
// get the device screen size.
CGSize winSize = [[CCDirector sharedDirector] winSize];
// set line smoothing
glEnable(GL_LINE_SMOOTH);
for (int i=4; i<winSize.height; i++)
{
CGPoint point1 = ccp(i*kTileSize, winSize.height - kTileSize);
CGPoint point2 = ccp(i*kTileSize, kTileSize);
// set line smoothing
glEnable(GL_LINE_SMOOTH);
// set line width
glLineWidth(0.4f);
// set line color.
glColor4f(0, 0, 0, 1.0);
ccDrawLine(point1, point2);
}
for (int i=0; i<winSize.width; i++)
{
CGPoint point1 = ccp(winSize.width - kTileSize, i*kTileSize);
CGPoint point2 = ccp(kTileSize, i*kTileSize);
// set line smoothing
glEnable(GL_LINE_STRIP);
// set line width
glLineWidth(0.4f);
// set line color.
glColor4f(0, 0, 0, 1.0);
ccDrawLine(point1, point2);
}
}
{
// get the device screen size.
CGSize winSize = [[CCDirector sharedDirector] winSize];
// set line smoothing
glEnable(GL_LINE_SMOOTH);
for (int i=4; i<winSize.height; i++)
{
CGPoint point1 = ccp(i*kTileSize, winSize.height - kTileSize);
CGPoint point2 = ccp(i*kTileSize, kTileSize);
// set line smoothing
glEnable(GL_LINE_SMOOTH);
// set line width
glLineWidth(0.4f);
// set line color.
glColor4f(0, 0, 0, 1.0);
ccDrawLine(point1, point2);
}
for (int i=0; i<winSize.width; i++)
{
CGPoint point1 = ccp(winSize.width - kTileSize, i*kTileSize);
CGPoint point2 = ccp(kTileSize, i*kTileSize);
// set line smoothing
glEnable(GL_LINE_STRIP);
// set line width
glLineWidth(0.4f);
// set line color.
glColor4f(0, 0, 0, 1.0);
ccDrawLine(point1, point2);
}
}
1 comentario:
Hola Laura enhorabuena por tu blog!
La verdad es que yo quiero iniciarme en Cocos2D y busco cursos, pero en la red hay poca info.
He encontrado este:
http://agbo.biz/tech/curso-cocos2d-basico/
¿Como lo ves? (ya que tienes experiencia)
Gracias por la ayuda
Publicar un comentario