範例是參考官方網站上的 Color Matching game。
CCNode內有一個新的屬性為physicsBody,為的是建立起Node的Physic運算,必須使用CCPhysicsBody來宣告其物件,並且設定。
但是單單CCPhysicsBody並無法成事。
好啦說了那麼多,直接看程式碼比較快囉!
2014年3月11日
2014年1月19日
自定義螢幕旋轉後的事件
舊東西放上來給自己筆記一下。
我們會動到的文件如下──
我們會動到的文件如下──
AndroidManifest.xml
MainActivity.java (或是其它的Activity類的Class檔案)
2013年11月24日
iOS螢幕旋轉觸發自定義function (xcode 5)
資料來源與參考:官方:Supporting Multiple Interface Orientations
iOS6之前使用的旋轉函式已經無法使用了,而是使用-(NSUInteger)supportedInterfaceOrientations與-(BOOL)shouldAutorotate來配合旋轉。
但是如果在旋轉後要呼叫自定程序去處理自定界面呢?
iOS6之前使用的旋轉函式已經無法使用了,而是使用-(NSUInteger)supportedInterfaceOrientations與-(BOOL)shouldAutorotate來配合旋轉。
但是如果在旋轉後要呼叫自定程序去處理自定界面呢?
2013年11月21日
進入XCode 5時代後,怎麼無法Archive
好不容易生成Provisioning Profile檔案,試著Archive,卻發生報錯:
Provisioning Profile的設定更正
或是
使用文本編輯器修改xcodeproj檔案
Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “XXXX”, however, no such provisioning profile was found.有兩個解決方案:
CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.0'
Provisioning Profile的設定更正
或是
使用文本編輯器修改xcodeproj檔案
2013年8月5日
讓另一個自定義ViewGoup物件能夠添加且顯示在自定義ViewGroup內
標題寫的很複雜,簡單來說就是──
我有一個自定義ViewGroup物件,稱為父親,要加入孩子,這孩子也是另外一個自定義ViewGroup物件。
雖然能夠成功addView進孩子,但是孩子卻羞澀的硬是不顯示出來。
──這不是孩子太過於害羞的問題!
而是你少告訴他你長多高多寬!
記得要在子自定義ViewGroup物件內的建構子中,加上:
我有一個自定義ViewGroup物件,稱為父親,要加入孩子,這孩子也是另外一個自定義ViewGroup物件。
雖然能夠成功addView進孩子,但是孩子卻羞澀的硬是不顯示出來。
──這不是孩子太過於害羞的問題!
而是你少告訴他你長多高多寬!
記得要在子自定義ViewGroup物件內的建構子中,加上:
this.setMinimumWidth(100);
this.setMinimumHeight(100);
2013年7月22日
2013年7月10日
讓你的View動起來──新版本
在4.0之前,讓View動作的語法如下:
UIButton *button = [[UIButton alloc] init];
CGRect frame = button.frame;
frame.origin.x = 500; // new x coordinate
frame.origin.y = 500; // new y coordinate
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.25];
button.frame = frame;
button.alpha = 0;
[UIView commitAnimations];
2013年5月21日
對每個child作class確認
以下是程式碼:
for (var i:uint = 0; i < this.numChildren;i++){
var child = this.getChildAt(i);
if (child is SimpleButton){
trace(child,"is SimpleButton");
}
}
2013年3月2日
取得網址的參數
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^]*)').exec(window.location.href);
if (!results) { return 0; }
return results[1] || 0;
}
來源:Get URL Parameters with jQuery | Improved
2013年3月1日
訂閱:
文章 (Atom)