Couldn't find the font file


#1

I used the .fnt font .I run my game successful locally.I can use the .fnt font
But I upload the game to the sever.
There are errors.
“GET http://www.epoching.com/zj/test/res/font/myFont.fnt 404 Not Found 13ms”
I do not know why


#2

Hi, Zheng Jie

It’s possible that you haven’t correctly preload the font file, you need to add it to your scene’s preload list like this:

    cc.LoaderScene.preload(resources_list, function () {
        director.replaceScene(new this.startScene());
    }, this);

Then you can use this font.

The possible reason that it works locally but not on your server, it’s because file can be loaded super fast.

Huabin


#3

no I wrote these codes :
cc.LoaderScene.preload(resources_list, function () {
director.replaceScene(new this.startScene());
}, this);

and the .mp3 file still couldn’t find

I was wondering if the errors are from server


#4

Hi, Jie

in resources_list, have you put the resource in it?
it should look like this:

var resources_list = [
    {src : 'res/font/myFont.fnt'},
    {src : 'res/Music/bgMusic.mp3'},
    {src : 'res/Music/bgMusic.ogg'}
]

Note that you need both .mp3 and .ogg file in your list, because chrome doesn’t support mp3, and safari doesn’t support ogg

Huabin


#5

no…not that proble
I change a server and it can find the .fnt. but couldn’t find the .mp3 file.
the console show:

GET http://www.codemt.com/demos/zj/Test/res/font/bitmapFontTest3.fnt
200 OK
1.31s

GET http://www.codemt.com/demos/zj/Test/res/audio/a_bg.mp3
403 Forbidden
752ms


#6

Sorry then, I don’t know how to help you for that, it’s probably a server issue.


#7

OK anyway thank you