Wednesday, September 26, 2012

An excellent site with loads of tutorials by Tim Roadley

Found this site by Tim Roadley with lots of tutorials and other very helpful information. He even has a game templates containing level selection similar to my Multiple Level Template, and I quite like his way of saving data to XML file for data persistence, might add that to my code soon.

Highly recommended!

Another issue with Appirater [with workaround]

Tried Appirater with my other game "Mespfi", which is a pure Cocoa game. Strangely as shown below, all the values stored in Localized.strings wouldn't load properly, only the key name been displayed instead.


First thought was Xcode 4.5 issue or not setup Localization properly after migrated to XCode 4.5, or the Localized.strings file problem. Tried lots of debug logging but still couldn't work out why. Then slowly back-out all the changes one by one, and found that when I disabled Appirater completely (remove the "#import "Appirater.h"" line in AppDelegate.m) then it starts working! What the...

Still not quite sure what's wrong, I then tried moving content from one of the Appirater Localized.strings file to mine and then delete it from Appirater, and it works! Looks like some sort of conflict betweens the new Localized.strings files from Appirater with my existing ones? I deleted all those extra language files which my App doesn't support, and merge the rest into mine, and all works ok after that...

Tuesday, September 25, 2012

Localisation in XCode 4.5 drives me crazy [Fixed]

Don't know why, after upgraded to XCode 4.5, testing localisation becomes a nightmare...

First I was stuck due to can't find the plus/minus buttons, finally found that it's been relocated after XCode 4.4, as I was on Xcode 4.3.3 before the upgrade, so wasn't aware about this.

Then found that if I change the language in simulator to Spanish, when it runs it's still in English. Deleted app from simulator, clean and re-run again, it works, then tried again, back to English again. Similar problem happens with the other languages too... I start wondering is adding multiple language support really worth the effort as I felt getting crazy after all these confusing, almost random test results...

Luckily, I found this work around by "VictorT". Listed below for your reference. I think it's adding extra step to copy the localizable.strings file over and to be honest don't really understand why, but most importantly - this fixed my problem!

  1. Remove application from device
  2. Select root node of project tree to get project's properties
  3. Select "Build Phases" tab
  4. Click "Add build phase" and select "Copy files"
  5. Select "Resources" in "Copy files" view
  6. Add Localizable.strings file
  7. Perform "Clean" for the project
  8. "Build and Run"

Issue with Appirater [With workaround]

I was adding Appirater to my game, however found a problem.

It works perfectly with iPad, as shown below:

However, when it's in iPhone, probably due to it's running in Landscape mode, there wasn't sufficient space to fit in both the title plus the message, therefore the message got cut-off...

I tried shorten the message, but then it would be very confusing. After some research, I found this post by Himanshu Sharma about how to change the font size, which is the most simplest solution for me. There are also others talking about creating fully customised alert view, but I think that's a bit too much for me. I just need a simple workaround to fit in my messages.

After a few adjustments, I shorten the message a bit, adjusted the font size to be smaller, remove the message body (use message as title), and got it sort of working as below. For iPad, I just leave it as it is.


If you look at the screen dump on Appirater site, you will see that it's in Portrait mode, that's why it can display the full message on iPhone.

If your game is in Landscape like mine, hope you find this work-around helpful!

Please let me know if there's any better way to fix this issue, as I really want the whole message title and body to be properly displayed in both iPad and iPhone without any workaround if possible.

Problem with TPG??

Tried to logon to my blog from home ADSL2 network, strangely Safari shows a blank screen and hung for a long time. Tried FireFox and this is what I got:

"Server not found" error for the top half, then a huge blue strip, then part of my last post at the bottom. What the??!!

Tried on my iPhone, and it loads up straight away!? Very strange.

I unplugged the network cable, use my iPhone's personal hotspot and everything works!

Must be problem with my ISP TPG and found all sites related to "xxx.blogspot.com" have the same problem. My iPhone uses Telstra network and has no issue browsing all sites. Looks like have to use my iPhone's "more expensive and slow" connection for tonight until issue resolved...

Lucky I have a backup, otherwise would be stuffed.

Friday, September 21, 2012

iPhone 3GS ARMv7 issue with XCode 4.5 fixed!

A not-so-happy start
At first I was a bit depressed today, as both my apps failed to compile in Xcode 4.5, plus from yesterday's bad experience - Xcode 4.5 won't generate the ARMv6 code to run on my old 3GS, then found old Xcode 4.3.3 disappeared, only have much older 4.2 left, looks like I might need to keep 2 versions of code !!??

What a mess...

Quickly worked out an action plan - I am going to uninstall Xcode 4.5, install Xcode 4.3 (or 4.4), then install Xcode 4.5 on a different folder - hope that they can co-exist. So that at least I can have the latest 4.3 or 4.4 to test the app on my 3GS, and then test on iOS 6/iPhone 5 (4 inch retina) simulator using Xcode 4.5. That's the best work around I can think of - until I got a replacing device (iPhone 5?) to test with... Hopefully very soon...

New discovery
Then while looking for further details about that ARMv7 error, I saw "PSA: Do not release ARMv7s code until you have tested it" from "Wandering Coder" talking about:

...when ARMv7 was introduced with the iPhone 3GS, ARMv6 kept being the default and there was an added “optimized” setting that built for but ARMv6 and ARMv7 if you wanted it...

Wait, what? ARMv7 was introduced with iPhone 3GS! So it's "iPhone 3G" that doesn't support ARMv7, my iPhone 3GS should be able to run ARMv7 code! But then why did Xcode 4.5 refuse to do it and complaints about ARMv7??

Further investigation...
Have a closer look at the error message again:


ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/qq/Documents/iOS.Dev.Projects/Where is it ?/Buzz.a for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Also read that article the second time, slowly. So it's actually complaining about "ARMv7s", not "ARMv7". And looks like "ARMv7" and "ARMv7s" (in the error message) are actually 2 different things!

Problem fixed
Following the article, I checked the "Architectures" values under "Build Settings", and as below, it says "Standard (armv7, armv7s)".



If I double click to modify the value, as shown below, it changed to "$(ARCHS_STANDARD_32_BIT)", no idea what does that mean...

I captured a screen dump as backup, removed the value and added new one "armv7" without the "s", and it works! Xcode 4.5 can now compile my app and install it on my 3GS successfully, yeah!

Huston, we got another problem...
The app starts up on the phone without problem, the splash page loaded, and then it crashed! WTF ##@$$%^&*(!!!...

Error message as below:


2012-09-21 17:32:07.425 Where is it[747:907] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
*** First throw call stack:
(0x359c52a3 0x3a3db97f 0x359c51c5 0x343d9897 0x3457e579 0x3445dd45 0x3445cfcf 0x359c89c4 0x3591ffeb 0x3457b733 0x3a7fbd2d 0x316c211f 0x316c14b7 0x316c2dcb 0x35998f3b 0x3590bebd 0x3590bd49 0x358392eb 0x343c5301 0xc0481 0x2d588)
libc++abi.dylib: terminate called throwing an exception 


Spent a lot of time adding different debug/logging but still couldn't workout what's wrong. Then googled the last line "libc++abi.dylib", also couldn't find anything related....

I almost gave up.... Then tried googling the "UIApplicationInvalidInterfaceOrientation" and found a work around!!

Problem #2 also fixed!
I followed the instructions:
1) enable all orientations in project summary
2) as my project uses Cocos2D, and don't have that "application:supportedInterfaceOrientationsForWindow", so nothing to remove
3) Add the extra code below in the RootViewController.m

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}

And it works! Yeah!

I guess I still have to switch back to "ARMv7s" and my old 3GS has to be replaced sooner and later any way, but at least I can hang on to it for a little longer while fixing both my apps for iOS6/iPhone 5!!

And I understand that once I switched to "ARMv7s" all the third party libraries has to be in "ARMv7s" too! Don't want to think about that now, already got lots of things to worry about that....

At least one major issue resolved, what a relieve...

[Update 22/Sep/2012]
You can find some other helpful info in Hacking up an armv7s library by Matt Galloway

Thursday, September 20, 2012

First day with XCode 4.5

Upgraded my iPhone 3GS to iOS 6 and quite happy to see the "Personal Hotspot sharing through USB not working" issue fixed.

However, after I downloaded Xcode 4.5 and tried to compile my 2 games, both failed... Still working on resolving the issues at the moment.

First it automatically asked to add this new launch image called "Default-568h@2x.png" - which is a really strange name. And it's an empty, black 640 x 1136 image.


Then there's lots of warnings about Cocos2D 1.0 library - as it still compiles, I just ignore it for now.

When runs in simulator, for "Where is it Smart Kids Edition" which is landscape, it shows 2 ugly black bars on both side.

While for "Mespfi", which is portrait, the ugly bars are now on the top and bottom...

I wasn't too worry about that as this just means some image adjustment plus UI changes.

However when I tried to run both apps on the physical device, both failed with similar error as below, one for Nextpeer and one for Buzzdoes.


ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/xxxxxxxxxxx/Buzz.a for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/xxxxxxxxxx/Nextpeer.framework/Nextpeer for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)



Thanks to Daniel/Nextpeer, looks like it's because Xcode 4.5 no longer supports the older arm v6 architecture on my old 3GS. I might have to maintain 2 versions of code - one for arm v6 and one for arm v7. But then when I searched through my MacBook Pro, found that the previous version Xcode 4.3.3 no longer existed and can only find Xcode 4.2!  Xcode 4.5 must have overwritten 4.3.3, what the....

Still wondering whether should I get a new iPhone 5, or just get the latest iPod and save the money for an Android phone. As I am a bit unhappy about the way Apple ignoring older devices and upgrading so frequently/quickly, felt a bit unsecured to invest all the effort and get locked into one single platform which changes so quickly... Oops, this reminds me about the Unity thing which I haven't touch for a week or now... I wish I can have more time doing all these development work.

[Update 24/Sep/2012]
Issue with "armv7s" error fixed by changing it to "armv7" and it runs on my iPhone 3GS without problem. For further details, please see this post. Thanks.



Sunday, September 16, 2012

GMail issue with iPhone built-in Mail app fixed

Spent some time testing different GMail settings, even installed this App called "Google Authenticator" to scan a QR Code (which is quite cool) - but this doesn't help at all. In the end it's this thing called "Application Specific Password" that fixed the problem.

Ok, if you provided your mobile number to GMail, you will have this security function called "2-step verification" enabled. Let me know if you got better idea, but so far the only way I can get GMail working with the iPhone built-in Mail app is by "Application Specific Password".

Any way, one annoying issue resolved... Move on to the next one...

Thursday, September 13, 2012

Just have to wait a few more days...

iOS 6 and XCode 4.5 would be available soon. Only thing that troubles me is how to change my app to cater for another new resolution (1136 x 640) for the new iPhone 5. Did some research and all I could see is this new file called "Default-568h@2x.png" in mentioned in a few pages.

There's even some sites (eg. this one) which posted a few screens about the new XCode 4.5 with "iPhone (Retina 4-inch)" simulator. Gee, I thought you are not suppose to do that??!!

Don't have the time to play with the GM build, so would have to wait for it's official release then... Hope it  won't be that difficult.... fingers crossed...

Seriously GoDaddy, you call that an apology email?

Received an email with the subject line saying "Please accept our apology and your enclosed offer" from GoDaddy and before reading it I thought they will be waiving some fee for 12 months or something like that to compensate all the trouble they have caused. Instead, as shown below, they ridiculously asking for more business, only offer 30% discount? and it's only available for the next 7 days??!! You got to be kidding me...


Never save sensitive information to NSUserDefaults

Just read something important from this "Basic Security in iOS 5" article on Ray Wenderlich's site that:

never save sensitive information to NSUserDefaults – these values are stored in PLAIN TEXT (i.e. just like this blog post) for all to see (and is also saved inside of your application bundle). Be mindful of what you put in there.

Which is quite interesting as I never know it's stored in plain text and also saved inside application bundle.

Wednesday, September 12, 2012

Applications are expected to have a root view controller at the end of application launch

Was testing the example game that comes with Nextpeer, and found this line in the log:


2012-09-11 23:24:19.571 ExampleGame[9101:15b03] cocos2d: Frame interval: 1
2012-09-11 23:24:19.573 ExampleGame[9101:15b03] Using Nextpeer version (1.2.10). https://api.nextpeer.com/v2/sdk
2012-09-11 23:24:19.857 ExampleGame[9101:15b03] Applications are expected to have a root view controller at the end of application launch
2012-09-11 23:24:19.857 ExampleGame[9101:15b03] cocos2d: surface size: 320x480
2012-09-11 23:24:22.441 ExampleGame[9101:15b03] cocos2d: Frame interval: 15
2012-09-11 23:24:29.960 ExampleGame[9101:15b03] cocos2d: Frame interval: 1


As I never seen this before, asked Daniel/Nextpeer and he confirmed it's not related to Nextpeer, but rather "has to do with how Cocos2D manages the UIWindow and root view controller objects for game. Nothing too serious :)"

Just not sure is Cocos2D trying to tell us something is not right? Compared to my other code, it seems it's because there's no RootViewController been used in the AppDelegate that's causing this to happen. As the app still works perfectly - which proves that Cocos2D can run without a RootViewController, so we probably can ignore that.

OpenGL error 0x0506 in -[EAGLView swapBuffers]

While integrating buzzdoes to my "Where is it Smart Kid edition" game, I found that if I trigger buzzdoes using the popup (when the app first loaded, not the button on the main menu), it will hung when I exit buzzdoes and return to game. Can see tones of error as below:


2012-09-12 23:53:24.717 Where is it[21084:707] failed to call context
2012-09-12 23:53:24.723 Where is it[21084:707] cocos2d: surface size: 480x320
2012-09-12 23:53:24.726 Where is it[21084:707] Failed to make complete framebuffer object 8cdd
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
OpenGL error 0x0506 in -[EAGLView swapBuffers]
.......


The strange thing is, it works without problem in simulator. It only hung and show this error message in the log when I test on the iPhone 3GS (iOS5.1.1) device. Found quite a few people on the net also had the same issue.

If I test it on the iPad 2 (iOS5.0.1) device, it also hung, but didn't show anything in the log...

Sent all these info to Arthur/buzzdoes, see if they can work out what's wrong...

The Cocos2D version I am using is 1.0.1 as shown below from "cocos2d.h"

// 0x00 HI ME LO
// 00   01 00 01


#define COCOS2D_VERSION 0x00010001


According to this old page, "0x0506 means: INVALID_FRAMEBUFFER_OPERATION_EXT" Urh.....What is that?

Continue researching....

[Update 16/Sep/2012]
Thanks to help rfom Arthur and Elad from buzzdoes, they released a fix and after a few test, the issue has been resolved. Though still don't know much about that OpenGL error, at least the whole thing is working ok now.

I could have submitted the current version to App Store as Arthur suggested, but I really want to wait 1-2 more weeks to get the app working and tested for iOS 6 and iPhone 5, at least in the simulator, as I am still waiting for the local telcos to release plans for iPhone 5.

Will do another few more days of testing, if all goes well, I might even integrate buzzdoes to my second game Mespfi too!

No Apple allowed?

Everyone must  be anxiously waiting for the new iPhone announcement like me. Was thinking of staying up for the news, but a quick Google shows 10 am Wednesday in San Francisco will be around 3 am Thursday Sydney time - still have to go to work tomorrow, so probably have to wait until tomorrow morning then....:-(

Ok, what's this "No Apple allowed?" thing I mentioned in the title, you might ask. Well, it's just that I recall seeing this sign a few weeks back:

If you compare it to the old Apple logo shown below, I think it's around 95% similar if you remove the circle and line. Don't you agree?


So, a sign saying "No Apple products allowed?" Well, technically, there's no clear explanation about what it is banning, but if I show you the whole thing you will get the idea. It's like this:

Yes, I guess it probably means "no food allowed" as it's next to the more-easy-to-understand "no smoking" sign. But why do they use the Apple logo??!! 

Where is this place? It's the Hyde Park Barracks Museum in Sydney...

View Larger Map

Hope this gives you a small laugh while waiting for the new iPhone announcement.... And hope Apple won't sue the museum and ask them to change the sign!!??!!

Sunday, September 9, 2012

Adding buzzdoes to my app

I tried adding buzzdoes to my Where is it - Smart Kids Edition today, it was quite easy and straight forward. To be honest, I actually spent more time on fixing the icon then the actual integration work...

First, you create an account and logon to their developer site, then click the "Add new iOS application" icon. You then have to download the SDK, and follow the instruction to setup your app.

The screen below shows the Apps screen, the 3 floating buttons were quite fancy. Please note that this is after I finished adding and configured my app, the "Application Name" will be different at the beginning before you configure it. You have to click on it, do some configuration (shown later) before it reads the settings and correctly shows your application name and icon.


Found 1st problem - not sure if it's because I am using the lowest "free" account, noticed I can't add another/second iOS/Android application after 1st one done? Nothing happened when I tried to click on those 3 icons.

[Update 11/Sep/2012]
The problem mentioned above seems to have been fixed somehow. I found a few problems during testing today (currently waiting for response from buzzdoes) and while doing other tests, found the button works now. As below, I just added another new iOS app, the name is "Test app for iOS", and a new App Key was provided automatically.


The configuration steps are quite straight forward too, just 3 steps as shown below. I got stuck at the first one for a while, as at first I thought it's asking for the "Bundle identifier", it's actually the "App ID" which is a long number. Adding a simple user-friendly help message (or example) would be helpful.



In fact, I didn't do these 3 steps configuration until I got all the code changes done and tested ok. Probably only need to do this if your app already published in the App Store.

For the actual integration part, as I mentioned above, most of time is playing around with the button image. As shown below, they only provide 2 sizes: 40x40 and 80x80, plus a vector file in ".ps" format which my Inkscape couldn't recognise. None of these meets my size (mine for iPhone: 96x96, for iPad 168x168), so have to manually increase the size. Plus, to create the effect of "been clicked", Cocos2D allows 2 images - normal and clicked for each button, so I have to add a semi-transparent, semi-cricle shape image on top to make it look consistent to existing ones.

The coding part is easy, just add the files and following the instruction. Except the provided info is for pure Cocoa code, as in Cocos2D the start up function is different (in applicationDidFinishLaunching of AppDelegate). But shouldn't be too difficult for you to work that out. And I am just replacing the email button, so there's not too much code change required for my app.

The screen below shows the only 4 files you need to add to your project. I created a group/folder to avoid confusion.


You then add 2 lines of code: 1st one to activate it at load time, 2nd one when you need it to popup. As below, when the app starts, it shows this nice looking screen encouraging your users to spread the word and get reward, quite nice!


Screen below shows what it looks like before and after the change on iPhone. Only if they can provide icons with different background colours.

The following from iPad 2, tested when internet connection is not available. A better looking graphic/image popup would be lovely.


This is the screen when it first started, I quite like the design.


As usual, you have to approve the terms of use first as the app will be reading your address book, Facebook contact, import gmail contact, ...etc. Urh... where is the "Yes" button? Should be "Accept"... Sorry, this is quite minor, I am just fussy...



 A few other screens shown below, you can login to either facebook or Gmail from here too and it will import all the contacts, quite cool!





I only tested the Gmail part, after you selected those people you like to spam, sorry I mean "Spread", it will create an email. I then noticed there are 3 recipients even though I only selected 2 contacts. Oh, found the reason why, it added an extra one call "spreads@buzzdoes.com".

As my mail app on iPhone doesn't work (see my other post for details), I tried it on my iPad, received the email and it works quite well.

The overall experience with buzzdoes integration is quite clean and quick, I think you should have a try in your app too!

Now that I got my apps updated, ready for submission to App Store! Let's see if this can double, triple or quad-triple my download rate... fingers crossed...

[Update 10/Sep/2012]
Found another issue, I was testing the display of different languages and noticed the buzzdoes screen didn't pop up at all, strange? Then noticed the following message in the log:

2012-09-10 16:57:41.547 Where is it[746:27007] buzzdoes is blocked for the chosen locale. Locales other than english are not available in the free plan.

So looks like if your app supports multiple languages, you have to either upgrade from the free plan, or disable it if it's not English!

[Update 12/Sep/2012]
Found another slight issue with buzzdoes on iPhone (doesn't happen in iPad), when the buzzdoes screen get triggered, it occupies the whole screen, and it rotates automatically if users rotate/tilt the phone to the side - which is not quite suitable for games mainly in specific mode (mine is Landscape). According to Arther/buzzdoes, you can manually set the orientation as below.

To set manually the orientation please use the following code:
[BuzzDoes BuzzSharedInstance].supportsPortraitOrientation=NO;

The optional properties are:
supportsLandscapeLeftOrientation
supportsLandscapeRightOrientation
supportsPortraitOrientation
supportsPortraitUpsideDownOrientation
Default value is YES.


 

Problem after added mobile to my GMail account

Can't remember when it started, when accessed from browser, Gmail keep popping up this extra screen asking me to add my mobile number for security reason after logged on. And even if you tried to skip it, it then shows you another annoying confirmation. What the %#$%^$&%^^$#$#.......


Until recently, I finally gave in and added my mobile. Seems ok at the beginning, just that if I logged in to a different machine, it will send me an SMS with verification code and I have to entered the received code to login. Well, it's for security, so can't complaint too much.

Then I found a major issue, yes, big one.

I have been using the iPhone buit-in Mail app to access my GMail from ages ago since I first got my phone. Yes, 3GS is very old now, hey, everyone is holding off their upgrade waiting for the latest iPhone 5 right?? Me too!

Any way, I found that since I added mobile number to GMail, my Mail app stopped working! It keeps telling me "The user name of password for Gmail in incorrect". I know my password and user name are correct as I can successfully logon from safari on the same iPhone!

You might say, well, just use safari or install Gmail app to read your mail then. Well, that only fixes part of the problem. Don't forget that the built-in Mail app is the default mail client on iPhone. If you are in an app with mail capability (e.g. Safari, ...etc) and want to send something to someone, the mail client that pops up is the Mail app - which is now no longer working! Or, please let me know if anyone knows how to change the "default" mail client on iPhone to "Gmail" app.....

Also, as shown below, when I first logon to the Gmail app, it also asked me to enter verification code sent by SMS.

So I start wondering, is it because after I logged on to the Mail app, it doesn't have the capability of processing that verification code thing and therefore failed the login process??!!

Mystery.... Any one got better idea or know how to fix it, please let me know! Thanks!

[Update 16/Sep/2012]
The official name of this security feature is called "2-step verification". And I fixed it, please see this post for further information.

Creating Git repository for existing XCode projects

This problem has been puzzling me for a while...

Scenario 1:
You started a simple project just for a quick/simple test.
XCode gives you option to "Create local git repository for this project", and for some reason you didn't/forgot to tick it...

After you spent some time on it, your simple proof-of-concept project seems to worth a lot more now and you want to add it to the source control. Ooops, how do you do that again??!! You tried every possible options under "File -> Source Control" menu but none of them works, what the....$%#@!

I guess it's mainly your fault for not creating the repository at the beginning, but, but, but, wouldn't it be nice if Apple can add an option into XCode to make it easier to add existing projects to the the source control?

Scenario 2:
There's another scenario - which happens to me quite a lot - you downloaded something from the web, you "heavily" modified it (it's mine now, mine mine mine! Ha ha ha....), and again, later wants to add it to source control and..... stuck again!

Finally found a solution today, thanks to this link by Ash Furrow, I learned that you have to:

(a) create an empty repository by open a terminal, go to your project directory and run the following commands:

git init
git add .
git commit -m "Initial commit"

(b) after that, follow the following steps (you may compress the whole project into a ".gz" file first if you worried about loosing anything...)


  1. Move your existing project folder to your desktop.
  2. Make a new, empty project in Xcode with the same name as your project. Make sure the box for using a .git repo is selected.
  3. Close Xcode.
  4. Copy all files from the project folder on your desktop to the new project folder Xcode created.
  5. Double-click the project file.
  6. You'll now need to add all the files to the source control since (they'll all have question marks beside them, shown right).

And you are done! Yeah, problem solved!

Saturday, September 8, 2012

Cocos2d Multi-level Template (including Cocos2d sliding menu grid)

At the beginning....
At first I was working on a proof of concept game, which is multi-levelled and I started thinking about how to create an "Angry Bird" style multi-level sliding grid. To avoid reinventing the wheel, I found this page from Apptinker blog which adds extra labelling for each level icons on top of Brandon Reynold's excellent piece of work (video shown below).


Some extras on top ....
However, after some testings, I found a few things that can be further improved:

(1) It's for iPhone only, doesn't cover iPad or Universal projects that well
==> need to check device type and use device specific parameters/images

(2) All level icons are clickable, which might not be very practical. As normally at the beginning, only the first one or few levels are enabled, rest all locked. Player has to pass the level (or pay extra money or click on ads or install other apps, ...etc to get credits) to unlock other levels. So it should have 2 types of level icons - locked and unlocked, and only those unlocked ones are clickable.
==> use different icons for locked/unlocked level types, plus extra field to keep track if each level is locked or not.

(3) Say if there are 3 x 6 level icons per page, and your total number of levels (e.g. 45) is not the multiples of 18 (e.g. 18, 36, 54, 72), scrolling to the last page (using 45 as example, that will be page 3 of clickable level icons) doesn't work.
==> add extra invisible icons (opacity=0) at the end to make the total number of all level icons equivalent to multiples of the number of total icons per page (45 + 9 invisible ones = 54 in total)

(4) From the level select page, can not return back to main menu page (the page before this page)
==> add extra HUD (Heads Up Display) layer with a home icon

Issues resolved, yeah!
I spent some time and finally got all these issues resolved. Also exchanged a few emails with readers about displaying splash page and localisation (supporting multiple languages) while working on this.

A light bulb appeared on my head, and....
I suddenly realised there's a need for a simple multi-level template which covers:
(a) splash page,
(b) main menu,
(c) level sliding grid,
(d) a simple popup at the end of each level,
==> if passed, unlock next level and show option to proceed to next level, replay same level, home or back to level select screen
==> if failed, only show option to replay same level, home to back to level select screen
(e) audio (one at splash page startup, one as looping background, a few sound effects, ...etc)
(f) localisation (for icon name and messages)

This should be handy to beginners like me, as you then only need to focus on the main game design, fit it into this template (with a bit of work of course), and you got a fully functioning game!

Wonder if there's currently any open source project available for this kind of work? Let me know if you are aware of any!!

Mission accomplished!
I got the first draft of this simple Universal project template sort of completed (link to source available far, far below), some features listed below:
(1) uses Cocos2d V1
(2) include script to run TexturePacker to build 4 ".pvr.ccz" format sprite sheets (iPad SD/HD and iPhone SD/HD) from 2 directories (containing images for iPad HD and iPhone HD) on each build
==> Note that if you only have the free version, you need 4 directories (one each) and have to use other file format which is slower and less efficient
(3) for localisation, includes English, Spanish, Traditional Chinese, Simplified Chinese and Japanese at the moment
(4) keeps track of top score, date top score achieved and number of stars received for each level (stored in NSUserDefaults)

Also have an empty link for Help and another one for GameCenter which I haven't got time to finish yet, will look at that later...

So, what does it look like? Some screen dumps and brief description first...
The application icon name, changes according to the language setting of the device. As the screen below shows, it's defined by "CFBundleDisplayName" inside file "InfoPlist.strings" and there's one for every supported language. Yes, your app can be called "XYZ" in Xcode, "ABC" in App Store, and shows "STU" at the bottom of icon when installed on users' device, they don't have to be the same.


Next, when the app starts, it shows the splash page. All the label/title content read from "Localizable.strings" file. You should get the idea now. The splash page code ("LoadingScene") also plays a short audio, you can use it to announce your company name or some other stuff to greet your users.



Note 1: with the Spanish version on upper right hand side, you can see a common problem - the label is too wide and need to reduce the font size to fix that! Please refer to this post of mine for further info: "Things learned about multi-language"
Note 2: the images with orange background are captured from iPad 2, the green ones are from iPhone 3GS.
Note 3: the blue popup in the middle is because I wasn't signed in to GameCenter, can ignore that.


Next is the main page, a bit too simple right? Yes, because I expect you to completely replace this page with a proper one for your game! (Note: latest version in the video was updated with extra Sound On/Off option)
"Help" and "GameCenter" not working yet, "Start Game" will bring you to the level select screen, "Reset" resets all the level data.

Next, the most important part thast most of you would be interested with - the level select screen (sliding menu grid). As you can see the "home" button floats in the HUD layer, doesn't move when you slide between different pages, and only 1st level was unlocked initially. Second one shows the last page - with 9 invisible ones at the back.


Finally the GameLayer - as you are also supposed to replace this with your own game, I quickly built a simply single page test game layer based on Ray Wenderlich's Cocos2D button tutorial to simulate the result of a real game. You can use the lower right hand side buttons to specify how many stars current level received, use the "+", "-" and 3 buttons above to change the score, and click on the middle 2 to pass or fail the game, very simple.

There will be 2 different popups when game ended depending on whether you passed or failed, as shown below:



Don't like the images/screen design? Me too...
Well, I am a developer, not designer... I am only providing a fully functioning "template", would suggest you to get some proper designer to do all the nice looking stuffs if you don't like mine, you are welcomed to change it!!


Short demo video
For those who like to see how it works, a short demo video covering both iPhone and iPad, as it's an universal project. Oops, as it's screen capture by QuickTime, unfortunately no sound... But if you download the source code and run from your Mac, you will get all the sound and background music.


Where is the code?!! Any copyright/left requirement thing?
I only have 2 simple requirements:

1) You have to download both my games and play both of them for a few times (help me to help you more!!)
  (a) Where Is It - Smart Kids Edition and (b) Mespfi

2) Optionally, please credit me or provide a link back to this blog either in your App or in your blog.

That's it, simple right? After that you are welcomed to use and change the code in which ever way that suites your needs.

Finally, you can click here (Updated V1.02) (Old Version 1.0 click here) to download the code. When you first run it, TexturePacker will report some errors (as it couldn't find the image files to process), but as the sprite sheets already included it will still work.

If you want to update any images (or fix that error), first you need to download the images, store it somewhere on your local drive, then modify "PackTextures.sh" so that all the path settings match where the images were located. And if you changed any of the image file names, please update the settings in "GameData.h" so that it can be picked up correctly.

I have put most of the changeable settings at the top of "GameData.h", have a look at that first.

Finally, please let me know if you have any problem, any further information required, or if you found any bug or have better ways to improve the project, all comments welcomed!

Thanks, and happy coding!

[Update 24/11/2012]
Thanks to Nick Wilson who pointed out that there's problem when this template runs in iOS 6. I have created a fix, please see this post for further details.

[Update 25/11/2012]
Updated links to source/images to V1.02, history info:

// Ver 1.00 - 28/09/2012 First version
// Ver 1.01 - 24/11/2012 Fixed iOS 6 orientation issue
// Ver 1.02 - 25/11/2012 Add background image for iPhone 5 (1136x640), add version number display on Main Menu


Credit
I used some Starburst Images from Vicki Wenderlich, followed tutorials from Ray Wenderlich for the HUD layer and the test game layer, and used quite a lot of stuffs from Steffen's excellent Cocos2d Book. The nice music is from redhouse91 on freesound.org, I hand-drawn some of the images, some are from OpenClipArt. So like to thank them for that.


Friday, September 7, 2012

Three Powerful 3D Software from DAZ 3D - free!

Got this info about DAZ 3D from friend, have a quick look and as shown below quite surprised to find that they are offering 3 of their Powerful 3D software for free (only 2 shown in screen dump below as image too long) - that's DAZ Studio Pro 4.5, Bryce Pro 7 and Hexagon 2.5, WOW! 


I heard about the name Bryce ages ago, but to be honest never really paid much attention about it as I wasn't into 3D until started learning Unity recently.

Had a quick look at some of the demo videos and quite impressed with it's powerful features. Wonder how that fits into the Unity world? It's free any way, quick! Go and download it before the free offer ends!

Saturday, September 1, 2012

Any one tried "buzzdoes"?

Thanks to a reader's comment, otherwise I never heard of the name buzzdoes before. Had a quick look at the site and found the concept quite interesting - when users clicked on the icon in your app, it lists out all the contacts and encourage your users to tap on it to recommend your app to friends. Pretty cool!

Wonder if any one tried this and what's the experience like (for integrating to your game/app)?

Actually, one of the main thing that caught my attention was noticing the famous game "Tiny Wing" listed in there. I thought there were some reports (e.g. this one) saying the game has "zero marketing" ??

I did try something similar with Ver 1.02 of my Where is it - smart kids edition by adding an email link to encourage users to send an email containing the link to install the game to friends so they can play together. However the way "buzzdoes"does it is definitely much more advanced and your users get rewards too, which definitely makes it more encouraging.

I am just still a bit unclear about the pricing details, the cheapest one is free with 100 "Successful Recommendation" - still not sure how that works. The help says:

buzzdoes motivates your users to recommend to their friend about your app.
We motivate them by giving them rewards, rewards that make the entire experience of telling a friend more enjoyable.
As a developer you set the reward you wish to give to your users. Your users will get those rewards only if their recommendation leads their friend to download your app. In case a recommendation leads to a download it is called Successful Recommendation.

Probably after you app been successfully recommended for 100 times, you run out of credit and have to upgrade to the next level - still no monthly fee but with $69.95 setup fee and it comes with 300 "Successful Recommendation". Mmm... Wonder what if I used up all my "Successful Recommendation" and didn't upgrade, does it stop my users from recommending my app??

Any way, I am busy working on a small project at the moment (no, not a game, but rather an open source template to share with all developers), will certainly give buzzdoes a try after I finish this project.