2010-01-05

轉換 .pvr 檔案格式

最近用 Cocos2d 載入一個背景圖頻頻出錯,原來是 Sprite 圖檔的長寬不可以超過 1024x1024!

如:Sprite *background = [Sprite spriteWithFile:@"BG02.png"];
要是 BG02.png 超過 1024x1024 就會出問題。
我試著把原稿縮小,再於程式裡放大,background.scale = 1.5f;

可是這樣比例又會跑掉了...


可以用 pvr 去處理圖片,但是找遍 Google 卻發現資源不多。
原來 pvr 的工具軟體就在 Xcode 裡。
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool

找到這份技術文件:
Creating textures in the PVRTC compression format

以及 OpenGL ES Programming Guide for iPhone OS 裡的 Using texturetool to Compress Textures

看來又要仔細研究一下了。

.

2010-01-02

討厭的 EXC_BAD_ACCESS

相信有很多人遇過 EXC_BAD_ACCESS 的錯誤訊息,有時候進 debug 也查不出個所以然,這種記憶體的問題,不管在哪種開發工具都會遇到。

而 Xcode 有個 Zombie 的方式,可以指出哪裡出問題!


從 Xcode 左側,展開 Groups & Files 內的 Executables 分類,點選 Project 名稱的項目,按右鍵選 Get Info。

切換到 Arguments 的標簽頁,在底下 Variables to be set in environment 下方有個「+」與「-」,按下「+」後,在「Name」輸入 『NSZombieEnabled』,「Value」輸入『YES』。

以後只要有物件建立,Zombie 也會自動建立,這樣在 debug 過程,如果有錯誤訊息發生,也可以透過 Zombie 找到進一步的問題點。

.

2009-12-17

用 Flash CS5 開發 iPhone 軟體教學


已經有教學影片了,而且這段影片還是直接切入平衡器(Accelerometer)的使用。
看來會有越來越多,很多有創意的朋友投入 iPhone 開發了!

Building iPhone Applications with Flash - Learn how to use Flash CS5 to compile your Flash applications into native iPhone app

Sneak Peak of Flash CS5 - Learn about all of the new features coming in Flash CS5 in addition to the iPhone workflow
網址:http://gotoandlearn.com/play?id=118

.

2009-12-11

免描述檔 App 安裝到 iPhone

這段內容是從 Pacess 的網站看到的,為了查詢方便,我將它節錄在這裡:

方法一:只適用於使用 Installous 安裝(需要 JB)
自從 Apple 把 Provisioning Profile 的期限改為三個月之後,久不久我便需要將 AppSales Mobile 的 Provisioning Profile 更新。於是我創作出解決方法,把 AppSales Mobile 變成自家製 IPA 檔案。方法如下:

1)建立 Payload 資料夾
2)把編譯好的 AppSales .app 拷到 Payload 內
3)把 Payload 壓縮成 ZIP 檔
4)把 Payload.zip 改名為 AppSales.ipa
5)把 AppSales.ipa 拷到 iPhone 裡的 /private/var/mobile/Library/Downloads
6)運行 Installous 安裝 AppSales.ipa

方法二:只需要用 iTunes 同步
01)建立 IPA 資料夾
02)在 IPA 資料夾內建立 Payload 資料夾
03)把編譯好的 .app 拷到 Payload 內
04)利用 BBEdit 打開 .app 資料夾內的 info.plist 檔
05)在 ((/dict)) 之前加入以下句子並儲存:
((key))SignerIdentity(/key))
((string))Apple iPhone OS Application Signing((/string))
06)把本來要上傳到 iTunes Connect 的 512x512 JPG 放到 IPA 資料夾
07)把 JPG 檔改名為 iTunesArtwork
08)把 Payload 及 iTunesArtwork 壓縮成 ZIP 檔
09)把 Payload.zip 改名為 Cracked.ipa
10)把 Cracked.ipa 拖拉到 iTunes 的 Applications 內
11)同步!

參考:http://pacess.blogspot.com/

ps.把「((」換成「小於符號」,「))」換成「大於符號」

.

2009-11-07

Xcode 常用技巧與按鍵

每個文字編輯軟體都有一些內定的技巧與按鍵,讓我們在編寫程式碼的時候很方便又有效率,列出來參考:

原文出處
http://iphonedevelopertips.com/xcode/xcode-tips-and-tricks-tips-1-to-10.html

Tip #1 – Split Editor View Vertically
If you like to have multiple code windows open at once, the Split Editor option is your friend (see the little square grid icon shown below).

By default, the windows are split horizontally. If you prefer to view your code side-by-side (nice for comparing), here’s how to tell the split to be vertical
Hold down Option key when clicking the Split Window icon

Tip #2 – Comment Out a Block of Code
You can quickly comment out a block of code as follows:
Select one or more lines of code to comment
Command-/
To uncomment a block of code, repeat the steps above.

Tip #3 – Toggle Between .h and .m Files (aka Switch to Counterpart)
Within your current code window, you can swap between the .h and .m file as follows:
Command-Option Up-Arrow

Tip #4 – Map Keys to Actions (Key Bindings)
The Switch to Counterpart tip above is a real time saver. However, I often find that if I map logical key-strokes to actions I’m much more likely to get into the habit of using them. For example, I mapped the Switch to Counterpart to Option-S, as in Swap or Switch.
Here’s how to set key bindings in Xcode
From the Xcode menu choose Prefereces
Select Key Bindings
Click on one of the Actions in the list
Tap on the Keys column on the right
Enter the keystroke you want to map to the action
Click Ok to save your changes

Tip #5 – Jump to API Documentation
Showing relevant API documentation for anything within the SDK(s) is as simple as:
Option Double-Click on relevant code
For example, in the screenshot below, after Option double-clicking on UIToolbar, a popup window shows a summary of the class information.

Tip #6 – Traverse File History
As you open and edit various files, Xcode keeps a history list of your actions, not unlike when using a web-browser. You can move through the list using the directional arrows as shown below:

The keystoke equivalent for the above is:
Option-Command Left-Arrow goto to previous file
Option-Command Right-Arrow goto to next file

Tip #7 – Set a Bookmark
I can’t imagine coding without having the option to set a bookmark as a placeholder for what I’m working on. I do this regularly when I need to segue to another file to find a snippet or otherwise poke around outside the current file I’m working on.
Setting a bookmark is as simple as:
Control-D
Enter a name for the bookmark

Tip #8 – Jump to Bookmark
There are two options to jump to a bookmark. First, you can select the bookmark icon in the upper right corner of the Editor window.

You can bring up the same menu as shown in the above figure using this keystoke:
Control-4

Tip #9 – Indent / Un-indent Code
You can indent a line of code or a selected block of code as follows:
Command-[ move code left
Command-] move code right
The above works regardless of where you are in a line of code, in other words, you don’t have to be at the beginning of the line.

Tip #10 – Zoom Editor
You can toggle between Detail view and Editor view by clicking the Editor button as shown here:

The keystroke equivalent of the above is:
Shift-Command-E