Cocos2D-Build Failed

Topics: Content Building and Deploying
Apr 29, 2014 at 2:55 PM
Edited Apr 29, 2014 at 2:55 PM
Hi everyone
I try to build cocos2d font by:
I create a font on http://kvazars.com/littera/ and pulish it by (xml and text).Then I create a project XNA for Window Phone on Window 8, I import cocos2d.Content.Pipeline.Importers. I can build TMX and plist file but when i build Cocos2d font (only file fnt) and I get this :
Error 3 Building content threw NullReferenceException: Object reference not set to an instance of an object.
at Cocos2D.CCBMFontConfiguration.ParseConfigFile(String pBuffer, String fntFile) in E:\Shared\cocos2d-xna\cocos2d\label_nodes\CCBMFontConfiguration.cs:line 112
at Cocos2D.CCBMFontConfiguration.InitWithString(String data, String fntFile) in E:\Shared\cocos2d-xna\cocos2d\label_nodes\CCBMFontConfiguration.cs:line 87
at Cocos2D.CCBMFontConfiguration..ctor(String data, String fntFile) in E:\Shared\cocos2d-xna\cocos2d\label_nodes\CCBMFontConfiguration.cs:line 49
at Cocos2D.Content.Pipeline.Importers.CocosFontProcessor.Process(String fileName, ContentProcessorContext context) in E:\Shared\cocos2d.Content.Pipeline.Importers\cocos2d.Content.Pipeline.Importers\Font.cs:line 28
at Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()
at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary
2& dependencyTimestamps, KeyValuePair`2[]& warnings)
Please help me.
Coordinator
Apr 29, 2014 at 9:26 PM
In all likelihood the "file='foo.png'" reference in the fnt file is the culprit. You always have to edit the fnt files after you produce them so that they are referencing the texture atlas properly.
Apr 30, 2014 at 2:33 AM
Thanks for your reply.
I tried add the folder location of foo.png .But the same error happen again

info face=Arial size=72 bold=0 italic=0 charset= unicode= stretchH=100 smooth=1 aa=1 padding=2,2,2,2 spacing=0,0 outline=0
common lineHeight=83 base=65 scaleW=361 scaleH=512 pages=1 packed=0
page id=0 file="D:\Study\C#\WindowsPhoneGame4\WindowsPhoneGame4\WindowsPhoneGame4Content\font.png"

Can you guide me how to correct reference?
Thank you.
Coordinator
Apr 30, 2014 at 6:41 AM
The paths in an XNA game use the relative path structure of the title container. All of the asset output must be included in the Content directory, e.g. Content/Images. Then those items under Content must be marked with CopyAlways or CopyIfNewer. Then when you refer to these content files in the game you must use a path that is relative to the Content directory.
Apr 30, 2014 at 8:54 AM
Thanks for your reply.
I tried every address but the same error happen always. Can you give me a project that can build those file ?. I just want to build .fnt to .xnb so I can add it to my project.
Coordinator
Apr 30, 2014 at 5:16 PM
The test projects that come with the GitHub source have FNT files that are produced into .fnt.xnb content.
May 1, 2014 at 4:19 AM
I knowed it. But I want to convert my own font.fnt to font.fnt.xnb. I tried the content.pipeline but at the end I can't convert .fnt to .xnb. And have tried your instruction... But nothing come to success. How did you handle bitmap font in Cocos2d-xna?
Coordinator
May 1, 2014 at 5:51 AM
https://github.com/Cocos2DXNA/cocos2d-xna/blob/master/tests/tests/classes/tests/LabelTest/BitmapFontMultiLineAlignment.cs

Line 44. Loading "markerfelt.fnt"

https://github.com/Cocos2DXNA/cocos2d-xna/tree/master/tests/testsContent/fonts

Scroll down and see markerFelt.fnt and markerFelt.png ... thassssssit!

My guess is that the FNT file produced by that web site has something that is not compatible with cocos2d. It's likely the path in the fnt file.
May 1, 2014 at 10:56 AM
Edited May 1, 2014 at 10:56 AM
I got it. Thank you. One more question :D. How did you convert .fnt to .xnb ?
Coordinator
May 2, 2014 at 10:43 PM
We use the content builder extension that is in the framework. that extension is only compatible with Microsoft XNA though. YOu will need Game Studio 4 installed on a Windows 7 or windows 8 upgraded machine for that to work.
Marked as answer by ziskadragon on 5/3/2014 at 6:23 PM
May 4, 2014 at 2:23 AM
I got it. Thank you very much for helping me :).