Skip to main content

Posts

EnvMap in CocosCreator

We wanted to get envmap effect implemented to ensure that we are able to show shiny surfaces. Since it wasn't clearly defined or showcased for cocos creator, i assumed it might not work. I wanted to make sure its' easy to setup so we don't loose a lot of time setting up a whole new renderer. Fortunately, the cocos creator engine has already setup the required pieces in place to get this working. I've been able to get this working on Cocos Creator 2.2.2. Here is the gist for implementing the same. Here is how it looks in action :

Google Analytics in Cocos Creator Web Games

Integrating google analytics for a web hosted cocos game is similar to integrating GA in normal websites. Add analytics.js download code to index.html use "ga" object to track events in the game.  This gets tricky if you want to do the same for a game that is running from within a mobile app. i.e, if you are embedding the web build from cocos creator into an android / ios app and loading it from disk for displaying in webview.  Add analytics.js download code to index.html Make GA use localStorage if you are not allowing cookies in webview. Disable the protocol detection in GA  Following is the code snippet to do it: Hope this helps anybody who is trying to achieve the same :)

H5 Engine Comparision

Recently i was trying to get a game out for the mobile web. I wanted something that would be able to publish light weight game and had a good workflow for artists and developers to get things going as soon as possible. Requirements: Support for Mobile Web GUI for level design Workflow for UI animation Support for 3D games Ability to publish for Native Mobile [Good to Have] The candidates: Unity (unity tiny)  Cocos Creator PlayCanvas Three.js I understand that other than the first two most of others don't have a way to publish to native mobile but the reason i choose them is because mobile web was the first priority and all of them seemed to have good support for it. Criteria Unity Tiny Cocos Creator Play Canvas Three.js 3D WebGL ❌ ✔️ ✔️ ✔️ UI Animation ✔️ ✔️ ❌ ❌ Particle Systems ✔️ ✔️ ✔️ ❌ Editor Support ✔️ ✔️ ✔️ ✔️ Custom Shaders Exp Exp ✔️ ✔️ Native Mobile ❌ ✔️ ❌ ❌ Based on ...

HTML5 games with Python

I am a big fan of HTML5 games. I understand their limitations but given the trend of high powered mobile devices and ubiquitous nature of the web, i believe it's one of the best ways to distribute simple and light weight games. I've been participating in PyWeek for a while now and have been trying to pickup and use different libraries available in python for game dev. The last two times i participated in PyWeek, i added partial support for cocos-creator in cocos (python version of cocos2d-x). This helped me accelerate the Development but i was always stuck with making builds that would fail on different operating system due to library handling etc. This is when i started to look for deploying Python code to web.. the first time around the only thing that i came across was pyjs/pyjamas which i was unable to get started with as they were blocked at python 2.7.* I needed something that worked with the latest of python. Recently though i came across " Transcrypt " ...

Network Time Sync

Synchronizing the time between client and server is pretty complex, I initially naively thought that using System.getCurrentTimeMillis() would somehow magically solve my problem. I realized quickly that this was not going to work as this is dependent on the current system time setting. The most appropriate solution to the problem is to use a common NTP server and ensure that the time is set right, but this is rarely a viable option when you have to deal with consumer level apps. We have to therefore resort to re-implementing or approximating the time sync. After searching through the web, this is the simplest one i could find and is what worked immediately and fixed our issues with time sync. TimeSync Equations Based on the above equation, we are able to calculate the time difference between client and server time stamps and hence reduce the errors in physics calculations. 

Thinking in ECS

If you have been following the new developments in the Unity Game engine, you would have found that they have been focusing on performance and modular code. One of the outcomes of this is a new way of writing code called "Entity Component System" where "Systems" operate on "Entities" which have various "Components" within them.  The ECS name is specific to Unity naming convention this "paradigm" also goes by the name of "Data oriented Programming". This could easily be mapped to how "C" programming works, or in general any functional programming works i guess.. "Systems" == "Functions" "Entities" == "Structures" "Components" == "Data Types / Unions" If we had to write a game engine in C i believe any reasonable programmer would write it this way, there would be an array of structures which contain the "position, rotation, scale" informatio...

Bone Rush (PyWeek26)

I've been a regular participant in the pyweek contest. The last time i participated, i tried to use cocos-creator to work as editor for cocos2d (python) and was fairly successful in creating a clone of Reigns (a mobile game about making choices). This time i wanted to replicate the rush fight game, where the faster you tap the faster the game moves. It's pretty fun mechanic and would fit well with the theme "flow". So i got to work with the same workflow i had before, create characters in inkscape and create sprites to be used in game. For a while i pondered about supporting skeletal animation using cocos-creator setup but was not sure if i was going to find time to do it, so i choose to go with sprite animations instead. Creating the sprites was a big deal as i was not sure if i wanted to setup the character in blender / cocos-creator / Inkscape for capturing the animation images. Inkscape quickly fell apart as an option as there was no way i could keep track...