Thursday, November 22, 2012

Conversion between CGPoint & NSValue (Mac)



To convert CGPoint to NSValue:

NSValue valueXY = [NSValue valueWithPoint:CGPointMake(X, Y)];


To retrieve CGPoint from NSValue:


CGPoint mPoint=[valueXY pointValue];





Icons for Mac App

This article also covers how to create .icns file which is used as icon for Mac Applications.


First,you need to create a folder with .iconset as suffix.
This folder will have following items with the dimensions mentioned and named as per screenshot.


  • icon_16x16.png
  • icon_16x16@2x.png
  • icon_32x32.png
  • icon_32x32@2x.png
  • icon_128x128.png
  • icon_128x128@2x.png
  • icon_256x256.png
  • icon_256x256@2x.png
  • icon_512x512.png
  • icon_512x512@2x.png

























You go into the directory where you saved icon.iconset folder and then  run following command on Terminal to create icns file.

> iconutil -c icns icon.iconset/

This will give you a single file as output named icon.icns in the same parent directory as icon.iconset, Add this file to resources of your application. Now in your project, you need to update the Icon name in Info.plist like in screenshot here.










Note: Apple documents say that you can add icon.iconset folder itself to your app's resources and Xcode 4.4 automatically creates .icns file for you. It also notes that "Don’t use Icon Composer—it can’t create high-resolution icns files."  . HERE IS THE LINK


Tuesday, November 20, 2012

Cocos2d For Mac

   Create a folder say(Cocos2DGame) where you want to download a copy of   Cocos2d:
   On your Terminal,
> git clone git://github.com/cocos2d/cocos2d-iphone.git

After this command a copy of Cocos2d will exist in Cocos2DGame folder. You need to step into Cocos2DGame folder by doing 
>cd Cocos2DGame
>git checkout develop

You need to install the cocos2d Mac Template in XCode
>sudo ./install-templates.sh

Now when you start a new project in Xcode, you will see the installed Cocos2d for Mac .



Note: You need to install git on your Mac Machine before you can run those git commands given above.

Download and Install dmg
http://code.google.com/p/git-osx-installer/downloads/list