Undefined SpriteFrameCache


#1

Hi,
I’ve made a simple game using cocos2d-js. On cocos simulator it works, but on browser I have trouble with one line:

var cache = cc.SpriteFrameCache.getInstance();

Which causes error:

TypeError: undefined is not an object (evaluating ‘cc.SpriteFrameCache.getInstance’)

looks like somehow cc.SpriteFrameCache does not exist on browser.

Tested on safari & chrome.


#2

I use singleton instead : cc.spriteFrameCache


#3

Thanks man!
Looks like I misunderstood documentation :slight_smile:


#4

You didn’t misunderstand the documentation. well over a year and they haven’t tested any of their Javascript tutorial OR API code. They should just drop Javascript if they aren’t going to support it.


#5

I also experience the same “undefined” error for:
var cache = cc.SpriteFrameCache.getInstance();
on the browser

I also have no issue with the same code in the simulator.
Does anyone know why this occurs and what I need to do to get it working on the browser?