Buy Me A Coffee!

GoPay

Tuesday, October 29, 2013

Error Compile Cocos2d-x di XCode 5

Terjadi keanehan tatkala diriku telah menyambangi XCode 5 bersamaan dengan Cocos2d-x
*Dan mengapa sekarang menggunakan bahasa Indonesia? Ulala, suka-suka saya lah, haha*

Ceritanya saya baru nginstall XCode 5 (sebelumnya pakai XCode 4). Pas compile projek lagi tiba-tiba.. tuing tuing tuing, muncul error "Apple Mach-O Linker (Id) bla bla bla..." diiringi dengan error-error lainnya.

Kalau nggak salah dulu pernah kejadian gini juga, langsung aja deh cari di Build Settings projectnya bagian Apple LLVM 5.0 - Language - C++ nya diganti dikit

C++ Language Dialect : GNU+98 [-std=gnu++98]
C++ Standard Library: libstdc++ (GNU C++ standar library)

compile lagi.. dan bisa! Alhamdulillah...

Kayaknya library Cocos2d-x ada sintaks yang nggak sesuai dengan penulisan C++ yang sekarang gitu ya?

Thursday, October 24, 2013

Less Ordinary Review Maverick OSX 10.9

After the shocking release announcement of freely available of the latest version of OSX, I hurriedly download this OS. Of course I was using my campus Wi-Fi, my mobile connection can’t download 5 gigs for several hour, it would take weeks. After that installing the OS for about one and a half hour, and here it is, the Maverick arrived at my Macbook.
Oh by the way, I’ve just bought Mountain Lion for $20 five months before. Maverick is free, and you can upgrade it from Snow Leopard. And what does it means? It means if I quite patient I could upgrade my OS, without buying it! Haha! Damn it Apple!

Oh, back to the review. If you are following tech magazine like Mashable, or Cult of Mac, or Engadget, you name it, you’ll get the review is about several things of Apple has told to public about this new OS. Let those big magazine fellas review about it, I’ll review about the other things then.



1. Looking Good Trackpadish Gesturish

Since the release of Lion, Apple introduce Launchpad that using gigantic pinch (it’s involving 4 or more finger, that’s why it was gigantic) in and out at your trackpad. But it felt unnatural for me. It was a little gesture pinch in and the Launchpad jumps in.But unnatural no more! Because you can hold your pinch a little longer to see the Launchpad blurring in!
It useful for those minutes of boring moments.

And also it happened for pinching out. And I love the inertia motion when you did that. Wooosh, those windows fly away to the sides.


2. Blurring Dock Background

Following its sister OS, iOS, the effect of blurring is come across Maverick as well. This looks nice.

3. Transparent Foldering 

Also like the iOS. I’ve afraid that it would be that “flying into the folder” effect. That would be scary effect for big screen. Fortunately Apple keep those sliding effect, but say goodbye to fabric-ish skeumorphic. Don’t get me wrong, I loved that background as well, but this one looks nice.

But

Holy Cow! DVORAK!

The installation was finished, and I want to type around at Spotlight, when suddenly… “What the heck? Since when it’s ASDF become AEOU?” That’s strange, the keyboard layout was Romaji!
Thanks goodness the trackpad didn’t become DVORAK as well (is that exist?), and I can delete add the US’s QWERTY layout. And everything back to normal. 

It’s still there

I love to move around between apps (mind my multitasking), and something weird is happened.
When I hover Twitter’s “follow” button of Twitter’s app the yellow box showing the information of follow status. And when I move to other apps using Cmd+Tab, that yellow box still there! Weird.. maybe it’s Twitter fault..

hover it

move to iTunes, still there!

Maverick feels good.

Beside of it's cheap price (huh, it's freeeee).... I don’t know, it just felt cozy and more responsive… till now. Maybe a week later I scream in honest for the spite of lag animation through my small free space hardisk  (Yes, it’s almost full. Thanks to my University’s assignments, and great downloaded-but-never-read-e-books). Hope you feel cozy about it like I do. Because it’s no longer big cat, but it’s a beach, that named after the dog. So radical, eh?

Wednesday, October 23, 2013

Today's Lab Of Cocos2d-X

I was experimenting to deploy my Cocos2d-X’s projects lab to my Android device. Surprisingly there were so many obstacles and ridiculous things bumped me. Here are 4 of them:

1. Compile configuration to Android

The configuration itself is not a piece of cake, especially on my newbie mind. Here are the step that you have to do

Part 1. Eclipse configurations


  1. Make sure you have your project (of course you have, you won’t compile it before you have something to compile, will you?)
  2. Import them into your Eclipse (the proj.android folder)
  3.  Import Cocos2d-X library for Android. It’s in [Your Cocos2d-X folder]/cocos2dx/platform/android/java.
  4. Right click your project (NOT THE LIBRARY), and select properties. Select “Android” tab and make sure you have ticked the target.
  5. Open project.properties, set the “target” to your target platform. For example I make mine this
  6. Open AndroidManifest.xml, and set the android:minSdkVersion to 14
  7. Right click your project folder, select “Android Tools” > “Fix Project Properties

Part 2. Compile commands configurations

  1. Go to your project’s android folder (proj.android folder).
  2. Open “build_native.sh” in your favorite text editor and at the top add this line
    NDK_ROOT="/Users/YOURUSERNAME/Development/android-ndk-r8e"
    a friend of mine told me it was unnecessary. Well it is necessary for Mac (I don’t know how to configure NDK_ROOT variable in Bash for default, but anyway, it works).
    Notes: As you can see I am using r8e version of android NDK. This is the only version that can compile Cocos2d-X 2.1.4 right.
  3. Head to “jni” folder
  4. Open “Android.mk” file. Make sure you have put all your class in LOCAL_SRC_FILES (it will contain HelloWorld and AppDelegeate class for default). This is the example from me:
    LOCAL_SRC_FILES := hellocpp/main.cpp \
                       ../../Classes/AppDelegate.cpp \
                       ../../Classes/Ball.cpp \
                       ../../Classes/GameScene.cpp \
                       ../../Classes/MenuScene.cpp \
    
  5. Open “Application.mk” and add this line for targeting your desired platform
    APP_PLATFORM := android-17

Part 3. Compiling


  1. Back to Eclipse. Select your folder, and run it. It will take a moment, so grab a snack or coffee. BEWARE OF ERROR (Google is your friend. No. Best Friend. No. It's your wife).
  2. Select your target device and scream in joy because you’ve deployed your app in your device.

2. Directly instantiate the initialization

So I have this game that need background of white. I simply add white layer first
CCLayerColor *layerWithColor;
layerWithColor->create(ccc4(255, 255, 255, 255));
addChild(layerWithColor);
Well, that’s looks okay. It’s compile smoothly on my Mac target, but no in Android target. The error is trivial and pops up when you run the game. You know what? You have to do this instead:

CCLayerColor *layerWithColor = CCLayerColor::layerWithColor->create(ccc4(255, 255, 255, 255));
addChild(layerWithColor);
That's insane!

3. No images in my device

So I was using a sprite sheet that sized 3000x500. But unfortunately in my device it won’t drawn and shown as black box instead. Why? Because the LogCat told me that:

cocos2d: WARNING: Image (3000 x 500) is bigger than the supported 2048 x 2048

4. Configuring path to Box2D

One of my experiment using Box2D. To compile it you have to tweak “Android.mk” file and add Box2D in your LOCAL_C_INCLUDES. I’ve found mine like this:
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
                    $(LOCAL_PATH)/../../../../external/Box2D \

UNSOLVED

Can’t call parent destructor from override

I’ve try to make game in Box2D and it require manual deallocation being called in destructor. In Mac target, I can write it like this

GameScene::~GameScene(){
    delete _world;
    _body = NULL;
    _world = NULL;
    CCLayer::~CCLayer();
}

But the compiler won’t accept ~CCLayer();. Hmmh… I don’t know why. If you know about this issue please tell me ASAP.

So that’s it! Enjoy your journey of Cocos2d-X!

Oh by the way, I am taking Game Programming course and using LibGDX. This engine is so simple and powerful. Have you ever using it? It’s in JAVA. Give it a try; you’ll love it too.