Neat Bundle Released!

I am happy to announce that Neat Bundle is released on iTunes App Store and is available for iPhones and iPads for free! So what are you waiting for, go grab your own version and start playing!

Also in other news, Naturals 2 is also available now for free from the App Store!

neatbundlecover

Neat Bundle is a collection of super-fun casual games in an arcade-like environment. Optimized for Retina iPad, it gives you a great high quality arcade experience on your tablet. Whether you play it on your phone or your tablet, you will get a nice challenging experience!

  • Earn gems by wandering through the galaxy and spend them on playing six different and totally cool games! Challenge yourself and your friends by unlocking achievements and setting your mark on different leaderboards!
  • Are you smart, quick and patient? Test yourself by challenging your brain with solving graph puzzles in Mesh, escaping from Noise-Activated Drones in the galaxy and blasting your way through a horde of enemies in Raid! Tilt the device and play the all-time favorite game Snake with new fun controls and compete with the others in Fall!
  • This bundle comes with six awesome games: Mesh, Raid, Drones, Tree Massacre, Fall and Snake. You can play a game by paying a Gem and you can find Gems in the mines!

Features:

  • High quality textures for retina display
  • Gem Mines: Find gems inside games and use them to play the other games
  • Achievements: Get +30 achievements and up to 1000 game center points!
  • Six different games!
  • Leaderboards: Compete with the world in seven different leaderboards!
  • Super Gem Charger: Earn gems faster every couple of minutes!
  • Accelerometer-based interaction to bring a more engaging experience to the user!
  • Regular updates with new newer games!

IMG_0019IMG_0007IMG_0021IMG_3424IMG_3421

Gotchas! Shaders in Cocos2d-x

I am planning to write quick tutorials about features in Cocos2d-x that are a bit tricky to use and are rarely (or not at all) discussed in tutorials and forums around the Internet. Basically these come from personal experience gained after not finding any good resources on the Internet. The first bunch of tutorials are going to be around the topic of shader effects (Fragment shaders), render targets and post effects.

[Notice: This tutorial is compatible with Cocos2d-x 3.1]

In this tutorial, I will go through how to use a different GLSL program (aka Shader effect) for each Cocos2d-x node.

Out of the box, each Cocos2d-x node can be set to use a different GL program. This is done by calling the setGLProgram(…) method of the desired Node object, and passing the GL program.

A GL program is defined using the GLProgram class. To configure your own GLProgram, follow these steps:

1. Create a new GLProgram object in the memory that uses generic.vsh as the Vertex shader program and generic.fsh as the Fragment/Pixel shader:

auto p = GLProgram::createWithFilenames("generic.vsh", "generic.fsh");

2. Create a Sprite node (or any other drawable node), and pass your GLProgram to its setGLProgram(…) method:

Sprite* dots = Sprite::create("dots.png");
dots->setPosition(CP(0.5f, 0.5f));
dots->setGLProgram(p);
addChild(dots);

That’s basically it. But you need the generic vertex and fragment shader template files to start from there. This would be a starting point for generic.vsh:

attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec4 a_color;
                   

varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
                               
void main()   
{                           
    gl_Position = CC_MVPMatrix * a_position;
    v_fragmentColor = a_color;
    v_texCoord = a_texCoord;
}

And for the fragment shader generic.fsh:

precision highp float;

varying vec4 v_fragmentColor;   
varying vec2 v_texCoord;
//CC_Time[1] is time, automatically updated by Cocos2d-x.

void main()           
{
    gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord);   
}

You need to put generic.vsh and generic.fsh in your Resources folder, and your job is done.

Note that in previous versions of Cocos2d-x, we needed to manually create a GLProgram object using the new keyword, and manually handle the task of deleting it. Basically making a GLProgram looks like this under-the-hood:

GLProgram* p = new GLProgram();
p->initWithFilenames(“generic.vsh”, “generic.fsh”);
p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
p->link();
p->updateUniforms();

 
 

Stay tuned for future related tutorials on Post Effects, Render Targets and Texture Repeating. If this was useful, please consider making a donation by using the donation link in my blog. Thanks.

New titles published on Google Play!

My new game “Naturals” which is a set of brain teasing puzzles based on natural numbers is now available on Google Play Store free of charge! This version of the game contains fifteen puzzles, and more puzzles will come in future updates. For more information about Naturals, visit its own page on my blog.

 

In addition, the first Quickie title, “Ball Fall” is also available on Google Play. More information about Ball Fall is available here.

If you are interested, you can get the complete cross-platform source codes for these games by making a donation via PayPal.

Fixing Cocos2D-x exe crash

During my cocos2D-x development with Visual Studio, I noticed that I can run my games pretty fine when I execute them via Visual Studio (F5 or Shift+F5,) but when I try to run the .exe file directly, it crashes.

After some trial and errors, I figured out that this crash is due to the .exe not being able to find game resources. To fix this crash just copy whatever’s inside your Resources folder to your Debug.win32 or Release.win32 folder and everything will run fine.