First thing to improve: project file
- Adding a new .js file, and adding a new resources file are done differently
- Js files should be added in
project.json
- Resource files should be added in
src/resource.js
We need to unify it… resources, files, etc must be added in one single place… just in one file. Probably in project.json
. project.json
should have an entry called “resources”, and the resources should be added there.
Update 1: Another thing to improve: auto-complete
When using Qt Creator (or Xcode) I feel super productive programming for C++ (or QML) because I have auto-complete… I also have the backup plan to jump to the header file (just one click away) and see all the definitions.
I don’t always remember the names of the functions, but I don’t have too.
Right now I’m using Atom + cocos2d-html5… and since I don’t remember the APIs (again, I never had to do that in C++) I’m not very productive.
We should add an auto-complete cocos2d-html5 plugin for the most popular editors (Sublime Text, Atom, etc…) (perhaps we already have them and I’m not aware of)
Update 2: Another thing to improve: samples + source code on the web
Since I don’t have auto-complete I need to go the webpage a find a good sample + source code page.
Since this is a JS engine, we must have that.
I know we used to have that page… but I cannot find it anymore.
Update to the update: It is here: http://cocos2d-x.org/js-tests/ (thanks @nite), but it is not exactly what I was looking for. We need something more simple to use. For example, if you want to create a LabelTTF there are many tests, but we don’t have any good sample (tests vs. samples: tests are good for developers, samples are good for users).
What we need is something similar to this: http://examples.phaser.io/
Update 3: Better error messages
I spent 20 minutes (or more) trying to find out why this line was not running:
var label = new cc.LabelTFF("hello", "Arial", 24);
The error message was:
Uncaught TypeError: undefined is not a functionMiniGame.js:7
It was I typo… I was using LabelTFF
instead of LabelTTF
… but the error message should be: “LabelTFF not found” or something like that. Perhaps this is not a cocos2d-html5 bug… but I don’t care… In order to be productive I need better error messages.
Update 4: Or no error messages at all
// this line should raise an error... I'm passing an invalid resource
new cc.Sprite(res.this_should_raise_an_error_since_I_do_not_exist);
but it fails silently
Update 5: tests seems to be based on cocos2d-js v2
I copy+pasted some code from here: http://cocos2d-x.org/js-tests/
but it seems that it is outdated. Some functions are never called, and some simple don’t “compile”.
Our online tests MUST be based on the latest stable version.
Update 6: improving events API
It called my attention that the event.getLocation()
returns the position in world coordinates.
The expected behavior for me is to return the position in local coordinates… but it could make sense if you want to install an event listener outside the scene graph… Controllers should be outside the scene graph, but also controllers are associated with a node… so what I’m saying is that it makes sense to have a event.getLocalPosition()
and event.getWorldPosition()
…
It is unfriendly to do the following:
// unfriendly
var target = event.getCurrentTarget();
var pos = event.getLocation();
var localPos = target.convertToNodeSpace(pos);
// much more user friendly
var localPos = event.getLocalPostion();
Update 7: small typo in the API:
Should be TOUCHES_ALL_AT_ONCE
instead of TOUCH_ALL_AT_ONCE
… semantically it means two different things.
Update 8: more events issues. No onMouseDragged??
WTF, there is no onMouseDrag
event.
Registering for the onMouseMove
and testing if a button is pressed is suboptimal.
Almost never users should register for the onMouseMove
event… it is extremely expensive since it generates too many events.
Digging further, I noticed that cocos2d-x also has this same limitation… ouch ouch! (must be added in v4.0)
Not sure if canvas supports the “mousedrag” event… in that case we should simulate it. Using cocos2d-html5 + JSB on a desktop will benefit of the native drag event support… but first we need to support it on cocos2d-x.
Update 9: Cocos Code IDE great features, needs more polish:
What I like of Cocos Code IDE
- code completion
- Test on web browser with one button
- Test on iOS with one button! (apparently it supports Android as well, but I haven’t tested it)
- Test on Mac with one button!
- have the possibility to debug on iOS and Mac, with breakpoints and everything
What I don’t like:
- Even though I have a very fast machine, it feels slow when doing almost any task
- Perhaps I have an old build, but I couldn’t get the javascript errors on the console, so it was difficult for me to identify the iOS bugs.
- I don’t like Eclipse… it is not very user friendly
My current dev. environment is:
- Atom + ack and debug + test on Chrome for 90% of the tasks
- Use Cocos Code IDE only to deploy for iOS
My ideal dev. environment would be:
- Decouple the “deploy to iOS / Mac” from Cocos Code IDE and add them into the
cocos
command line
- And from Atom deploy to iOS for quick testing.