减少 cocos Label创建位图集

1.在 CCFontAtlas.cpp文件中

把默认的图集从515*512 创建成 256 *256

const int FontAtlas::CacheTextureWidth = 256;

const int FontAtlas::CacheTextureHeight = 256;

//下面的合并慎用

2. 在CCFontAtlasCache文件中的getFontAtlasTTF 函数中

FontAtlas* FontAtlasCache::getFontAtlasTTF(const _ttfConfig* config) 改成

FontAtlas* FontAtlasCache::getFontAtlasTTF(const _ttfConfig* in_config)

//记得.h文件也要修改成in_config哟

把不用描边的字体当成一种,减少位图的大小

//modify by pcw 为了减少字体贴图,强制修改描边

_ttfConfig* config = (_ttfConfig*)in_config;
if (config->outlineSize > 1){
config->outlineSize = 1;
}


if (config->fontSize >= 11 && config->fontSize <= 20){
config->fontSize = 18;
}
else if (config->fontSize >= 21 && config->fontSize <= 26){
config->fontSize = 23;
}

3.在UIText.cpp中 enableOutline 函数

void Text::enableOutline(const Color4B& outlineColor,int outlineSize)
{
//add by pcw 为了减少字体贴图种类,强制修改为1
outlineSize = 1;


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
cocos2d-lua中,你可以使用loadTextures函数来加载图中的纹理。该函数的定义如下: ```lua Btn:loadTextures(normal, selected, disabled, texType) ``` 其中,normal参数是正常状态的纹理名称,selected参数是选择状态的纹理名称,disabled参数是禁用状态的纹理名称,texType参数是纹理资源类型。你可以使用空字符串来表示没有对应状态的纹理。 如果你想加载本地散图,可以使用以下代码: ```lua Btn:loadTextures("", "", "", ccui.TextureResType.localType) ``` 或者 ```lua Btn:loadTextures("", "", "", 0) ``` 如果你想加载图中的纹理,可以使用以下代码: ```lua Btn:loadTextures("", "", "", ccui.TextureResType.plistType) ``` 或者 ```lua Btn:loadTextures("", "", "", 1) ``` 这样就可以在cocos2d-lua中使用图来设置按钮的纹理了。 #### 引用[.reference_title] - *1* *3* [cocos2d-lua:Button loadTextures加载按钮纹理](https://blog.csdn.net/fightsyj/article/details/89286392)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [cocos2d-lua性能优化 (腾讯游戏学院)](https://blog.csdn.net/u013321328/article/details/108793253)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值