[Game] In Progress - Creating a game from scratch

I think this is a great idea.

Also if the workflow is the same, it shouldn’t be too hard to translate it to Lua for example.
I’m particularly interested in the iAP, Ads, Analytics part as it is probably less documented than the rest.

Watching closely!

And propably the last thing, unfortunately.

Thank you for your answer. Sounds very promising :smile:

C++:) I do not know how to write JS.

You guys could post your workflow, to show how to start and finish, for me is easy to start, but to finish… But I want to know how do you do the things.

@iQD, i second the motion bro!
Cocos2d-X is such an incendiary game engine, but it’s hard to do IAP.

C++ too! . There’s more things you can do with native languageas coz they have the hardware to back it up. But great job! Maybe it’s time I learn JS too :smiley:

BTW how nice of you to choose Puzzle and Dragons, the no.1 game in Japan. :smiley:

@reyanthonyrenacia
why its hard to do IAP?
i never did it can you elaborate on this ?

  1. Coz im a noobie in objective C.
  2. Most examples are meant for pure iOS apps, using Obj-C to implement IAP, like examples by Rey Wenderlich.
  3. It requires bridging, which Im not comfortable with… yet.

anyways, my friend did it for me so…we have IAP now :stuck_out_tongue:

The problem with IAP is, that on mobile platforms, you don’t really have freedom on how, when and where you implement IAP or other features. Mobile platforms are closed platforms. The platform provider dictates the rules. If you are not following those rules, your game will not be accepted or even will be kicked from the app store.

The SDKs you have to use, are implemented in a specific language(C++, Java, Obj-C) and you have to implement bridging code, if your game is implemented in another language. Implementing the bridging code can sometimes be cumbersome and error prone or unflexible, if the SDKs incorporate major changes and rule-sets. To make that job a little easier, people provided some tools/code you can rely on, like EasyNDK, AnySDK, Soomla or plugin-x.

Things would be easier and more flexible if the platform holders provide a REST API or would be (more) open to different third party SDKs/solutions. Unfortunately they are not giving you that freedom, as they want to assure the same “user experience” throughout the games on the specific platform, but the main point in not being “open” is, that they can enforce their revenue share of 30-40%. With an open solution, a developer could cut out the middle-man and could receive up to 90-100% of revenue.

IAP is not hard to do on it’s own, but the platform providers made it hard to do on purpose.
Different rule-sets have different policies how IPA has to be implemented. Presentation, credential handling, restoring of bought assets and so on. Not all platform holders require a restore button or using their IAP APIs or specific presentation rules, price tiers and what not. Some even have different price tiers/revenue shares based on the developers’s country/region.

All these “enforcements” make IPA “hard to do”. It’s made hard by artificially means.

C++ on linux :stuck_out_tongue:

1 Like

Great. I will follow up with you! I’d love to learn how to integarte Ads. window store, mac store, etc.

I love cocos2d-js engine. Great that you will use JS. Thanks

cocos2d-js uses jsb to bind the javascript code to c++ on native platform. The performance is as good as cocos2d-x. I don’t see the reason to use cocos2d-x. I am using cocos2d-js for everything.

that only counts for stuff where you are using cocos2d-x core…

So, @nite and I are here in a cafe coding the game…
The repo is here: https://github.com/darkdukey/PeriodicQuest
And we are discussing it on the IRC #cocos2d channel of Freenode: http://webchat.freenode.net/

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 :frowning:

Update 5: tests seems to be based on cocos2d-js v2 :frowning:
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.

Why aren’t you using cocos code ide?

@Michael good point. Probably I should try it. Although I’m not a fan of Eclipse… It feels slow.
How do I import an already created project into Cocos Code IDE?

It’s really worth it!

Import a already created cocos project:

  • File
  • Import
  • Cocos - Import Cocos Project
  • Select project directory
  • Finish

Just make sure that you set the settings under:

  • Window
  • Preferences
  • Cocos
  • Python Location, SDK Location, NDK Location, ANT Location, JDK Location, Frameworks Engine Mode (I think you are using Engine Mode)