我想了解使用的東西CCUIViewWrapper在cocos2d與停靠的功能的利弊的利弊。例如,在CCUIViewWrapper中使用UITableView還是使用CCTableViewSuite會更好?乍一看,我認爲包裝是更好的方法,因爲它可以讓我做UITableView提供的所有東西,但是我錯過了關鍵細節嗎?包裝中是否存在嚴重的限制,無論是實際使用apple sdk對象還是無法利用Cocos2d中與CCTableView等移植對象一起提供的某些功能?優點和使用CCUIViewWrapper與停靠的功能
回答
我抄自here這個職位,可以幫助回答你的問題。我相信用cocos2d包裝器來使用cocos2d函數會更好,但是你可以用其他人來實現它,但它也不會被集成。
如果有需要額外的幫助如何使用cocos2d的一個UIKit的項目集成任何新手(像我一樣)在那裏,這可能幫助。正如你在這個線程的第一篇文章中讀到的,Blue Ether編寫了一個用於處理UIViews的包裝器。什麼是UIView?看看http://developer.apple.com/iphone/library/documentation/uikit/reference/uikit_framework/Introduction/Introduction.html,向下滾動一下,你會看到不同UIView項目的圖表;像UIButton,UISlider,UITextView,UILabel,UIAlertView,UITableView,UIWindow等等。其中有超過20個。您可以使用藍色Ethas代碼將它們中的任何一個包裝在cocos2d中。在這裏我將包裝一個UIButton,但試驗你最喜歡的UIView項目。
創建一個新的cocos 2d應用程序項目。
建立一個新的NSObject文件,並調用它CCUIViewWrapper。這會給你的文件CCUIViewWrapper.h和CCUIViewWrapper.m。編輯(通過複製粘貼)他們,使他們看起來像藍甲醚定義(請參閱第一篇文章在這個線程。
讓你HelloWorld.h這個樣子
// HelloWorldLayer.h #import "cocos2d.h" #import <UIKit/UIKit.h> #import "CCUIViewWrapper.h" @interface HelloWorld : CCLayer { UIButton *button; CCUIViewWrapper *wrapper; } +(id) scene; @end
和你HelloWorld.m這樣
// HelloWorldLayer.m
#import "HelloWorldScene.h"
// HelloWorld implementation
@implementation HelloWorld
+(id) scene
{
CCScene *scene = [CCScene node];
HelloWorld *layer = [HelloWorld node];
[scene addChild: layer];
return scene;
}
-(void)buttonTapped:(id)sender
{
NSLog(@"buttonTapped");
}
// create and initialize a UIView item with the wrapper
-(void)addUIViewItem
{
// create item programatically
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Touch Me" forState:UIControlStateNormal];
button.frame = CGRectMake(0.0, 0.0, 120.0, 40.0);
// put a wrappar around it
wrapper = [CCUIViewWrapper wrapperForUIView:button];
[self addChild:wrapper];
}
-(id) init
{
if((self=[super init])) {
[self addUIViewItem];
// x=160=100+120/2, y=240=260-40/2
wrapper.position = ccp(100,260);
[wrapper runAction:[CCRotateTo actionWithDuration:4.5 angle:180]];
}
return self;
}
- (void) dealloc
{
[self removeChild:wrapper cleanup:true];
wrapper = nil;
[button release];
button=nil;
[super dealloc];
}
@end
建立和運行。這應該在場景的中間產生旋轉按鈕,你可以觸摸按鈕同時轉動。它會寫在控制檯的文本消息。
CCUIViewWrapper是不是一個很好的解決方案。我試過並將其刪除。問題在於它將UIKit元素封裝在容器中,並將其作爲導向器上的視圖添加到openGL主視圖中。與此相關的一個問題是,您將無法在其上添加任何其他精靈。非常有限。
- 1. 與CCUIViewWrapper錨點問題
- 2. 如何實現WPF停靠功能作爲Visual Studio停靠功能
- 3. 點擊功能和懸停功能
- 4. 功能指針的優點
- 5. 功能樣機的優點
- 6. 優化與功能
- 7. 如何使用停靠窗口和非停靠在一起
- 8. 使用點擊功能禁用jquery懸停功能
- 9. 使用Netbeans的Gits功能可靠嗎?
- 10. Javascript點擊和懸停功能需要
- 11. 合併懸停和點擊jQuery功能
- 12. 關於懸停和點擊功能/ jquery
- 13. jQuery的 - 與停止功能
- 14. sortOn功能與優先
- 15. 如何使用Android的ProGuard只能與優化功能
- 16. jQuery抽屜與懸停和點擊功能
- 17. 停止使用Javascript功能
- 18. 懸停功能使用jQuery
- 19. 點擊功能停止工作懸停功能
- 20. 通過點擊功能停止懸停功能
- 21. 的div和懸停功能
- 22. 使用VCL停靠:如何使垂直停靠的表單勝過水平停靠的表單?
- 23. 懶惰多功能的優點?
- 24. 對象內組功能的優點
- 25. jquery懸停與.each功能
- 26. 如何使用Apple Carbon處理停靠點圖標點擊
- 27. 如何列出與使用GTFS的路線相關的所有停靠點?
- 28. 簡單英語回電功能的優點與實例?
- 29. 懸停功能 - 。在懸停和點擊後製作border-bottom
- 30. 使用appendTo和加載點擊功能
嗨RubberDuck你喜歡什麼,而不是CCUIViewWrapper?謝謝 – yatanadam 2012-10-31 19:52:48
最好的選擇是使用cocos創建自己的控件,而不是使用UIKIT。 – SpaceDog 2012-11-01 09:11:26