Custom ttf font makes Spritekit's transition slow in SWIFT

孤街醉人 提交于 2019-12-23 23:40:53

问题


I am having trouble with transition when using custom ttf fonts for spritekit in swift.

I realized that when I use the code below my app gets laggy and slow for only the first time. Are there any way to fix this issue? Are there any examples or tips?

let loadLabel =  SKLabelNode(fontNamed:"Silom")

        loadLabel.text = "Loading ....."
        loadLabel.fontSize = 30
        loadLabel.fontColor = SKColor.whiteColor()
        //loadLabel.position = CGPoint(x:self.size.width/2, y: self.size.height/2 )
        loadLabel.zPosition=2

回答1:


As pointed already, if the font name is misspelled, a loading delay can occur. But, the name of the font you pass when creating SKLabelNode is not necessarily the same as the filename of the font. You can use Fontbook to find the actual font name or you could do something like this:

for family: String in UIFont.familyNames()
{
     print("\(family)")
     for names: String in UIFont.fontNamesForFamilyName(family)
     {
         print("== \(names)")
     }
}

After you find a font name, remember to remove this code snippet from your project.

Also, make sure that you have:

  • Included your custom font in your application .plist file
  • Checked that your font is included as resource in your bundle (Target->Build Phases -> Copy Bundle Resources.


来源:https://stackoverflow.com/questions/33330247/custom-ttf-font-makes-spritekits-transition-slow-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!