CCLabel设置两位格式
sprintf(string, "%2.2f Test", m_time);
设置格式为00:00
CCLabelBMFont::create("00.0", "fonts/bitmapFontTest.fnt");
设置格式为00:0
图片后缀
cclabelatlas:plist+png
cclabelbmf:fnt
cclabelttf:ttf
copy
动作比如fade,被sprite1和sprite2同时使用,需要用到copy
label1->runAction(repeat);
label2->runAction( (CCAction*)(repeat->copy()->autorelease()) );
透明度和色彩变化
BMP图片在透明度和色彩变换上都可以很好的完成效果,但是有透明像素比如说PNG的就不如它,但是你可以告诉XCode不要压缩图像
获取一串字母中的一个,进行动作
CCLabelBMFont *label = CCLabelBMFont::create("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");
CCSprite* BChar = (CCSprite*) label->getChildByTag(0);
BChar->runAction(rot_4ever);
cctexutre渲染label
ccV3F_C4B_T2F_Quad quads[] = //{{顶点坐标}, {顶点颜色},{顶点UV坐标}}数据
{//UV就是将图像上每一个点精确对应到模型物体的表面. 在点与点之间的间隙位置由软件进行图像光滑插值处理. 这就是所谓的UV贴图.
{
{{0,0,0},ccc4(0,0,255,255),{0.0f,1.0f},}, // bottom left
{{s.width,0,0},ccc4(0,0,255,0),{1.0f,1.0f},}, // bottom right
{{0,s.height,0},ccc4(0,0,255,0),{0.0f,0.0f},}, // top left
{{s.width,s.height,0},{0,0,255,255},{1.0f,0.0f},}, // top right
},
{
{{40,40,0},ccc4(255,255,255,255),{0.0f,0.2f},}, // bottom left
{{120,80,0},ccc4(255,0,0,255),{0.5f,0.2f},}, // bottom right
{{40,160,0},ccc4(255,255,255,255),{0.0f,0.0f},}, // top left
{{160,160,0},ccc4(0,255,0,255),{1.0f,0.0f},}, // top right
},
{
{{s.width/2,40,0},ccc4(255,0,0,255),{0.0f,1.0f},}, // bottom left
{{s.width,40,0},ccc4(0,255,0,255),{1.0f,1.0f},}, // bottom right
{{s.width/2-50,200,0},ccc4(0,0,255,255),{0.0f,0.0f},}, // top left
{{s.width,100,0},ccc4(255,255,0,255),{1.0f,0.0f},}, // top right
},
};
//需要添加到纹理中才能绘制
for( int i=0;i<3;i++)
{
m_textureAtlas->updateQuad(&quads[i], i);
}
另外写出重写函数draw进行绘制
void Atlas1::draw()
{
m_textureAtlas->drawQuads();
}
设置垂直间隔
menu->alignItemsVerticallyWithPadding(4);
设置label水平和垂直
m_plabel = CCLabelTTF::create(this->getCurrentAlignment(), "Marker Felt", 32, blockSize, m_eHorizAlign, m_eVertAlign);
不成功,字符乱码?
Using 2 .fnt definitions that share the same texture atlas."
//绘制长方形
void LabelBMFontBounds::draw()
{
CCSize labelSize = label1->getContentSize();
CCSize origin = CCDirector::sharedDirector()->getWinSize();
origin.width = origin.width / 2 - (labelSize.width / 2);
origin.height = origin.height / 2 - (labelSize.height / 2);
CCPoint vertices[4]=
{
ccp(origin.width, origin.height),
ccp(labelSize.width + origin.width, origin.height),
ccp(labelSize.width + origin.width, labelSize.height + origin.height),
ccp(origin.width, labelSize.height + origin.height)
};
ccDrawPoly(vertices, 4, true);
}
//设置字符宽度
CCLabelBMFont m_pLabelShouldRetain->setWidth(labelWidth);
sprintf(string, "%2.2f Test", m_time);
设置格式为00:00
CCLabelBMFont::create("00.0", "fonts/bitmapFontTest.fnt");
设置格式为00:0
图片后缀
cclabelatlas:plist+png
cclabelbmf:fnt
cclabelttf:ttf
copy
动作比如fade,被sprite1和sprite2同时使用,需要用到copy
label1->runAction(repeat);
label2->runAction( (CCAction*)(repeat->copy()->autorelease()) );
透明度和色彩变化
BMP图片在透明度和色彩变换上都可以很好的完成效果,但是有透明像素比如说PNG的就不如它,但是你可以告诉XCode不要压缩图像
获取一串字母中的一个,进行动作
CCLabelBMFont *label = CCLabelBMFont::create("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");
CCSprite* BChar = (CCSprite*) label->getChildByTag(0);
BChar->runAction(rot_4ever);
cctexutre渲染label
ccV3F_C4B_T2F_Quad quads[] = //{{顶点坐标}, {顶点颜色},{顶点UV坐标}}数据
{//UV就是将图像上每一个点精确对应到模型物体的表面. 在点与点之间的间隙位置由软件进行图像光滑插值处理. 这就是所谓的UV贴图.
{
{{0,0,0},ccc4(0,0,255,255),{0.0f,1.0f},}, // bottom left
{{s.width,0,0},ccc4(0,0,255,0),{1.0f,1.0f},}, // bottom right
{{0,s.height,0},ccc4(0,0,255,0),{0.0f,0.0f},}, // top left
{{s.width,s.height,0},{0,0,255,255},{1.0f,0.0f},}, // top right
},
{
{{40,40,0},ccc4(255,255,255,255),{0.0f,0.2f},}, // bottom left
{{120,80,0},ccc4(255,0,0,255),{0.5f,0.2f},}, // bottom right
{{40,160,0},ccc4(255,255,255,255),{0.0f,0.0f},}, // top left
{{160,160,0},ccc4(0,255,0,255),{1.0f,0.0f},}, // top right
},
{
{{s.width/2,40,0},ccc4(255,0,0,255),{0.0f,1.0f},}, // bottom left
{{s.width,40,0},ccc4(0,255,0,255),{1.0f,1.0f},}, // bottom right
{{s.width/2-50,200,0},ccc4(0,0,255,255),{0.0f,0.0f},}, // top left
{{s.width,100,0},ccc4(255,255,0,255),{1.0f,0.0f},}, // top right
},
};
//需要添加到纹理中才能绘制
for( int i=0;i<3;i++)
{
m_textureAtlas->updateQuad(&quads[i], i);
}
另外写出重写函数draw进行绘制
void Atlas1::draw()
{
m_textureAtlas->drawQuads();
}
设置垂直间隔
menu->alignItemsVerticallyWithPadding(4);
设置label水平和垂直
m_plabel = CCLabelTTF::create(this->getCurrentAlignment(), "Marker Felt", 32, blockSize, m_eHorizAlign, m_eVertAlign);
不成功,字符乱码?
Using 2 .fnt definitions that share the same texture atlas."
//绘制长方形
void LabelBMFontBounds::draw()
{
CCSize labelSize = label1->getContentSize();
CCSize origin = CCDirector::sharedDirector()->getWinSize();
origin.width = origin.width / 2 - (labelSize.width / 2);
origin.height = origin.height / 2 - (labelSize.height / 2);
CCPoint vertices[4]=
{
ccp(origin.width, origin.height),
ccp(labelSize.width + origin.width, origin.height),
ccp(labelSize.width + origin.width, labelSize.height + origin.height),
ccp(origin.width, labelSize.height + origin.height)
};
ccDrawPoly(vertices, 4, true);
}
//设置字符宽度
CCLabelBMFont m_pLabelShouldRetain->setWidth(labelWidth);