Cc.TMXTiledMap is undefined

Cc.TMXTiledMap is undefined
0.0 0


I’m having a hard time loading in a TMX map. Can anyone take a look at what I’m doing and point me in the right direction?

var Scene1 = cc.Layer.extend({
        return true;

        var map = cc.TMXTiledMap.create("Assets/Maps/area01.tmx");


I’m getting the following error with this: “TypeError: cc.TMXTiledMap is undefined”


Can you attach a basic TMX file? I’ll give this code a shot in my app.

EDIT: On my initial test (without a valid file), I’m getting the same error in Web Inspector:

Uncaught TypeError: Cannot call method 'create' of undefined

It’s point at Line 22 in my code:

map = cc.TMXTiledMap.create('./Resources/test.tmx');

Perhaps this requires the instantiation with new? Example:

map = new cc.TMXTiledMap('./Resources/test.tmx');

I get a different error when I try that, but I’m not sure whether the error is because test.tmx doesn’t exist, or something else.


Another possibility: CCTMXTiledMap appears to be defined here:


The tutorials I’ve seen do not import this. Specifically, your cocos2d.js file, where all the cc.loadjs calls are made. You may need to add additional calls there to load the contents of the tileMap_parallax_nodes folder. At the very least, the CCTMXTiledMap.js file, but to be safe, maybe all files?


That solved it. I was not importing all of the necessary files. I needed CCTMXTiledMap.js and there were a handful of dependencies. I just grabbed this list of files from the “tests” folder.

Is there a good way to sort out which files I need and which I don’t? Or is it best to just to have them all?

Thanks very much for the help.


I’m not actually sure myself. Minimalist way would be to add one file at a time whenever you encounter this sort of “Class is undefined” behaviour. Safest way is to mass load I guess. I haven’t seen any documentation about these sort of dependencies, but I’ve only been using this framework for a few days so it may just be that I haven’t come across it yet.


I ended up using the Ant build script to combine all the class scripts. That worked very well. Minimized scripts containing all of the classes are already included in the “tests” folder.