Sunday, 13 April 2014

Run Cocos2dx Android Project on Windows


I assume you have already created Android project using template provided with Cocos2dx and imported it in your Eclipse workspace using from existing Android project option and converted it to C/C++ nature.

Also I assume you have installed Android NDK and set up correct path in Eclipse and your workspace location is Cocos2dx default directory.

Note:This method does not require either cygwin or python to run Android project on Windows.

Software's: Cocos2d-x-2.2.2, Windows 8.1 64-Bit and Eclipse 4.4

Step 1: Add Environment Variables

 
Go to Eclipse -> Window -> Preferences -> C/C++ -> Build -> Environment

And add NDK_ROOT and NDK_MODULE_PATH in Environment variables:

1) NDK_ROOT
            F:\Android\NDK\android-ndk-r9
2) NDK_MODULE_PATH :
            F:\Coco2dx\cocos2d-x-2.2.2;F:\Coco2dx\cocos2d-x-2.2.2\cocos2dx\platform\third_party\android\prebuilt

* Note:
If you are using version Cocos2dx-2.2.3 then you don't need to add path for prebuilt modules in NDK_MODULE_PATH. You can only use path F:\Coco2dx\cocos2d-x-2.2.3;




Step 2: Link Resources


Now in your project you have to link your Resources and Classes folders to your eclipse project:

You have to create two folder link named classes and assets If assets folder already exist then delete and recreate it.

To create folder link :
Select Project -> Right Click -> New -> Folder -> Advanced

Linking Classes :
Type classes in folder name and select Link to alternate location (Linked Folder) and type PARENT-1-PROJECT_LOC/Classes

Linking Resources :
Type assets in folder name and select Link to alternate location (Linked Folder) and type PARENT-1-PROJECT_LOC/Resources




Step 3: Setting  C/C++ Builder

Select Project -> Right-Click -> Properties -> C/C++ Build -> Builder-Settings
Uncheck Use default build command option and enter ndk-build.cmd in Build-Command and then click Apply and then click Ok. 

Now eclipse will start building your whole Cocos2dx Android project.





This method build projects faster than Cygwin because Cygwin runs under emulated environment and usually it takes longer time to copy resources to assets directory when you build and run your projects.

Monday, 20 January 2014

Handle back key event in Cocos2dx 2.2.2 Windows Phone 8 XAML and C++

Cocos2d-x-2.2.2 version has introduced new project template based on XAML and C++ Component  for Windows Phone 8 platform which allows you to develop games with C# and C++ mixed. You can use XAML components using this template but it's missing BACK key event handling which is primary key for Windows Phone application navigation. However there is a work around which allows you to handle BACK key in your C++ Component based game.

Open CocosRenderer.cpp and change the OnBackKeyPress() method as following:

bool Cocos2dRenderer::OnBackKeyPress()
{
    //return false;
    CCDirector::sharedDirector()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
    return true;
}



You can override virtual void keyBackClicked();  method in your Game Layer and handle back key event.

Tuesday, 1 October 2013

Full screen Command Prompt on Windows 8

When you work with development environments where you needs to interact with command line debugging tools then it becomes very annoying work on Windows 7 and Windows 8 Command prompt window, because by default it opens a very small sized windows and you can not directly maximize them. However you can set manual width and height from properties but again its annoying job because once you have setup manually it won't save settings permanently. Hence here is another way you can use.

1) Open Command Prompt (Cmd)
2) Type "wmic" and hit Enter
3) Press "Alt + Space + X" and hit Enter
4) Type "quit"

This trick simply opens Windows Management Instrumentation Command-line utility which allows you to work in full screen mode. However if you want truly full screen Command prompt then must try Dos emulators like "DOSBox" etc.

* Note : - use all commands without double quotes.

Wednesday, 18 September 2013

Tuesday, 10 September 2013

Remove hidden apps on Windows Phone 8

There are many apps in Windows Phone 8 which are per-loaded by Nokia/Samsung/HTC etc. displayed in settings menu. This all apps are great added features from OEM's but some times many apps doesn't work as expected and crashes randomly. I have seen this problem with the apps like Storage-Check, Feedback to Nokia etc. And if you want to remove or reinstall them then there is no option. But here is a trick that can easily do this job for you.

1) Change your device date to DD-MM-2112 and restart device.


2) Go to settings menu and select options like "Storage-check", "Feedback to Nokia".


3) A message will come with title "Problem with app", read the message and if you want remove it then select uninstall option.



This trick simply expires the date of security certificate with the application. Therefore whenever we open any app then system ask us to either Uninstall or Buy the application.