Using custom fonts in Cocos2d(在 Cocos2d 中使用自定义字体)
问题描述
如何在我的 Cocos2d iPhone 应用程序中使用自定义 TTF 字体?
How do I use custom TTF fonts in my Cocos2d iPhone apps?
推荐答案
我搜索了一段时间,并决定发布为想要实现的人的问答.
I searched for this for a while and decided to post as question and answer for people wanting to implement.
解决方法很简单.
找到您想要的字体并下载它们.本网站拥有大量免费字体.
将字体文件添加到您的项目中.
Add the font files to your project.
以下面的数组为例,将字体名称添加到您的 info.plist 文件中.
Add the font names to your info.plist file using the array below as an example.
查找字体名称;双击字体文件并使用窗口标题中显示的字体名称.在这个例子中是动作人"
Find the font's name; Double click the font file and use the font name shown in the title of the window. In this example it is "Action Man"
按照您通常的方式使用字体名称:
To use the font name the way you would normally:
CCLabel* myLabel = [CCLabel labelWithString:@"Some Text" fontName:@"Action Man" fontSize:18];
将此添加到您的 info.plist 文件中:
Add this to your info.plist file:
<key>UIAppFonts</key>
<array>
<string>Action Man Bold.ttf</string>
<string>AdineKirnberg-S.ttf</string>
</array>
这篇关于在 Cocos2d 中使用自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Cocos2d 中使用自定义字体


基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01