本文整理汇总了C++中CCTexture2D::drawInRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTexture2D::drawInRect方法的具体用法?C++ CCTexture2D::drawInRect怎么用?C++ CCTexture2D::drawInRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTexture2D
的用法示例。
在下文中一共展示了CCTexture2D::drawInRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void HelloWorld::draw()
{
//这里需要绘制格子了。。
CCPoint pt1;
CCPoint pt2;
for (int i = 0 ; i < 16 ; i++)
{
for (int j =0 ; j < 8; j++) {
int x = m_CurrentMapStartPos.y +j;
int y = m_CurrentMapStartPos.x +i;
if (map[x][y] != 1) {
ccDrawColor4B(255, 0, 0, 125);
}
else
{
if(map[x][y] == 2){
ccDrawColor4B(0, 255, 255, 125);
}
else
{
ccDrawColor4B(0, 255, 0, 125);
}
}
pt1.x = i*64 ;
pt1.y = j*64+m_border;
pt2.x = (i+1)*64;
pt2.y = (j+1)*64+m_border;
ccDrawRect(pt1, pt2);
{
char num[20];
CCTexture2D* tex = new CCTexture2D();
sprintf(num, "%d,%d",(int)m_CurrentMapStartPos.x + i,(int)m_CurrentMapStartPos.y +j);
tex->initWithString(num, "Arial", 15);
CCRect rect = CCRectMake(pt1.x,pt1.y,30,30);
tex->drawInRect(rect);
tex->autorelease();
}
}
}
char PlayerPos[20];
CCTexture2D* tex = new CCTexture2D();
sprintf(PlayerPos, "playerPos:%d,%d",(int)m_CurrentPos.x,(int)m_CurrentPos.y);
tex->initWithString(PlayerPos, "Arial", 15);
CCRect rect = CCRectMake(10,700,100,30);
tex->drawInRect(rect);
tex->autorelease();
char CurrentmapstartPos[20];
CCTexture2D* tex1 = new CCTexture2D();
sprintf(CurrentmapstartPos, "CurrentmapstartPos:%d,%d",(int)m_CurrentMapStartPos.x,(int)m_CurrentMapStartPos.y);
tex1->initWithString(CurrentmapstartPos, "Arial", 15);
CCRect rect1 = CCRectMake(10,730,100,30);
tex1->drawInRect(rect1);
tex1->autorelease();
CCLayer::draw();
}