Cocos2dx-js is Here!

SOOMLA is happy to announce our new solution: Javascript – based economy model for cocos2d-x.

Cocos2dx in app purchase for mobile app game developers,a new javascript function.

Cocos2dx-js In a nutshell

SOOMLA is broadening options for Cocos2dx in app purchase, and has created Javascript bindings for its Cocos2d-x store project.  This means that Cocos2d-x developers can now use SOOMLA in their Javascript based games to create a virtual economy in simple, intuitive Javascript code.  Get the code here:

Cocos2dx-js In detail

In the last several months the Cocos2d community is working hard to cooperate their efforts around getting more friendly for game developers. The community has issued several coordinated releases for 3 major frameworks: Cocos2d-x, Cocos2d-iphone, Cocos2d-html5 – all sticking to the same APIs to the possible extent. But the most significant outcome of these efforts is that currently it’s possible to create games for each of these platforms using only one programming language. It’s Javascript. It means that today developers are able to implement all the logic in JS, and wrap it with Cocos2d-x to publish for mobile or wrap it with Cocos2d-html5 to to publish on the web. It’s pretty evident how it works for Cocos2d-html5, but this framework is out of scope of this post. The more interesting things happen with Cocos2d-x. While the Cocos2d-x guys created a high-performance C++ framework, it could be strange to hear that they made a big step to integrate a scripting language. The silver bullet of their approach is SpiderMonkey.

“SpiderMonkey is Mozilla’s JavaScript engine written in C/C++. It is used in various Mozilla products, including Firefox, and is available under the MPL2.”

The Cocos2d-x team created js-bindings for all significant C++ classes and methods of the framework. And now you are able to call this code from JS. Actually, JS is used only as a glue for all the game logic, while all the framework calls are performed on the native side. As a result we have minimal performance impact on one hand, but on other hand we get plenty of attractive abilities for our products. In order to stay the most comfortable virtual economy solution in the world, we strive to provide game developers a solution for their platform of choice. That is why we’ve implemented a javascript solution for Cocos2d-x. Let me briefly introduce how it works with the following case.  You have an internal currency (currency_muffin), which could be purchased with a pack (muffin_pack_1000). And you have your a virtual good (fruit_cake) with price 225 of your currency. Let’s create metadata for them.

Currency:

Currency Pack:

Virtual Good:

After putting it into your instance of Soomla.IStoreAssets, and getting Soomla initialized you should create an event handler and get it subscribed to IAP events.

Now you’re able to start purchasing:

That’s all.  And here’s all the code put together to see the big picture:

 

Check out our docs on Github for detailed step by step instructions for integrating SOOMLA with Cocos2d-x JS: https://github.com/soomla/cocos2dx-store

To get a quick head start, we’ve also created an example project for this solution: https://github.com/soomla/cocos2dx-js-store-example/.

Make sure to also check out the SOOMLA project in other technology flavors.

Looking forward for your feedback and contribution.

Feel free to share:

5 COMMENTS

    • We currently don’t have any guide to work inside Cocos IDE. If you manage to get it working and would like to create a short article about it, we’d be happy to feature it in our blog and add it to our Knowledge Base.

  1. @disqus_inLfixg6j3:disqus We currently don’t have any guide to work inside Cocos IDE. If you manage to get it working and would like to create a short article about it, we’d be happy to feature it in our blog and add it to our Knowledge Base.

LEAVE A REPLY

Please enter your comment!
Please enter your name here