Question

<rant> I swear dealing with IDE problems are the worse. Its like all I want to do is get my hands dirty with some code but can't. </rant>

As the title suggest I am trying to get Cocos2d-HTML5 working in Visual Studio 2012. I have coppied the Cocos2d-HTML5 files to my web directory and followed a few of the tutorials but am having a problem with jsloader.js.

Prior to the change below it was not finding the jsloader.js :

   FROM:  `engineDir: '../cocos2d/',`
   TO:  `engineDir: '../GridWars/cocos2d/'`

Gridwars is the name of the project

Now it finds jsloader.js but has an error.

Unhandled exception at line 117, column 5 in http://localhost:51244/GridWars/cocos2d/platform/jsloader.js

0x800a138f - JavaScript runtime error: Unable to get property 'loadExtension' of undefined or null reference

for these lines of code:

var d = document;
var c = d.ccConfig;

if (c.loadExtension != null && c.loadExtension == true) {
Was it helpful?

Solution 3

The answer was posted on their release notes. I was following one of their tutorials and ended up finding my answer at the bottom of the post.

ANSWER:

in cocos2d.js

look for "s.c = c",

change it to "document.ccConfig = c"

in main.js

look for "config:document.querySelector('#cocos2d-html5')['c'],"

change it to "config:document.ccConfig,"

OTHER TIPS

Which version of Cocos2d-html5 did you used?

It is required to configure your settings in the cocos2d.js file. You may find this file in the template folder.

For example:

var c = {

    COCOS2D_DEBUG:2, //0 to turn debug off, 1 for basic debug, and 2 for full debug

    box2d:false,

    chipmunk:false,

    showFPS:true,

    loadExtension:false,    //**Hey, here is the loadExtension.....**

    frameRate:60,

    tag:'gameCanvas', //the dom element to run cocos2d on

    engineDir:'../cocos2d/',

    //SingleEngineFile:'',

    appFiles:[

        'src/resource.js',

        'src/myApp.js'//add your own files in order here

    ]

};

v2.2 has a similar error. I found that moving a line around in your cocos2d.js file helps.

window.addEventListener('DOMContentLoaded', function () {
    ...
    d.body.appendChild(s);
    document.ccConfig = c;
    s.id = 'cocos2d-html5';
    //else if single file specified, load singlefile
});

Remove the line: document.ccConfig = c; and move it before the window.addEventListener

eg:

document.ccConfig = c;

window.addEventListener('DOMContentLoaded', function () {
   // etc
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top