CCLabelBMFont Multiple Dependancy warning.

I’ve been trying to upgrade from an older version of cocos2d-x to the newest version and I’m currently going through and fixing errors that have occurred.

The big one for me now has to do with font working with multiple resolutions.

I’m only using one font and in my old project I had 2 .png files (Font.png and Font-hd.png) and 2 .plist files (Font.plist and Font-hd.plist) and this worked brilliantly.

Now my understanding is that the multi-resolution code has changed and you no longer need the -hd suffix and instead use serperate folders to hold the different files dependant on their resolution and then set a different search path. My first question is this correct?

Secondly, is this the same for fonts? I have a Fonts folder in my Resources folder. In the Fonts folder are two folders names iphone and iphonehd and they each have the Font.png and Font.plist files that correspond to the resolution they are meant to contain. However I am getting an odd warning in xcode stating “Multiple build commands for output file”. Ofcourse this is the case, I have two files named the same thing but in different folders.

I think this is linked to a bug I’m having where the game is using the higher resolution assets on my lower resolution device. It only does it sporadically but its still a bug I need to fix before release.

Correct, you would have:-
Resources
SD
Font.png
Font.plist
HD
Font.png
Font.plist
IPADHD
Font.png
Font.plist

I wonder if you are getting the error because xcode is interested plist files?
What happens if you change the extension to .xml or .fnt?

I’m using BMFont and multi res resources and dont have an issue (my files are .fnt and .png files).

Sorry, I wasn’t clear. I use .fnt files for my fonts and .plist for my spritesheets

My folder structure is like this

Resources
-iphone
—Sprites.png
—Sprites.plist
-iphonehd
—Sprites.png
—Sprites.plist
-Fonts
—iphone
—Font.png
—Font.fnt
—iphonehd
—Font.png
—Font.fnt

(Bold text means Folder names)

About 50 of the time I have no issue. The warning is there but the game will run perfectly using the correct assets for sprites and fonts. The other 50 of the time the wrong assets are used and I get an error saying “copyPNGFile Error” refering to the font file along with the warning even though the game manages to run.

This may or may not be relevent but I also have a warning message stating “Incomplete Implementation” in EAGLView.mm on the line “@implementation EAGLView”. It says “Method ‘selectionRectsForRange’ in protocol not implemented”

If my folder sturcture is the problem then that ok, its an easy fix but I suspect it might be more than that.

Is this for iOS?
Have you added your folders as references (are the folders blue in xCode)?

Yes its for iOS, and no the folders aren’t blue they are yellow.

That will be why sometimes you get the wrong resources.

Remove the folders and re-add them as references, that should fix it.

It might also fix the plist issues but I’m not 100% sure.

I think this is my own lack of knowledge letting me down here, but can you explain why that would help please?

If you don’t add the folders as references then only 1 copy of the file will exist in the package.

I had the same issue in my app, some times the wrong resource file was loaded.
Add the references fixed it for me.

He meant on Xcode. When adding folders, make sure to add them as references and not groups.

You folder structure should be this:

Resources
- SD
- - FileA.PNG
- - FileB.PNG
- - Fonts
- - - Font.PNG
- - - Font.FNT

- HD
- - FileA.PNG
- - FileB.PNG
- - Font
- - - Font.PNG
- - - Font.FNT

- XHD
- - FileA.PNG
- - FileB.PNG
- - Font
- - - Font.PNG
- - - Font.FNT

Thanks for the input guys, it appears to be working now (sorry for the late reply)