I am having an issue with Cocos2d-js, where it doesn't seem to think that cc.EditBox exists. I create a new project and try to delcare:
var box = cc.EditBox.create(...)
And I get this error in my browser console:
Uncaught TypeError: Cannot read property 'create' of undefined
I cannot figure out why this would be the case. Within the project directory I can even see that frameworks/cocos2d-html5/extensions/editbox
exists and contains the files CCdomNode.js
and CCEditBox.js
.
Does anyone have an explanation and/or solution?
It's a common error, the problem is that EditBox
is an optional module.
You need to add "editbox"
to the modules
list in your game's project.json
file, and then cc.EditBox
will be defined.
Like this
"modules": [
"cocos2d",
"cocostudio",
"editbox"
],