0
我看到了有關使Button類用於在cocos2d一個真正偉大的職位:http://johnehartzog.com/2009/10/easy-to-create-buttons-with-cocos2d/容易在cocos2d創建按鈕2.0
我喜歡這個主意,因爲它確實簡化了按鍵的創作,但他似乎使用的是老式版本的Cocos2d和我無法讓他的代碼工作。
@interface Button : Menu { // !Cannot find interface declaration for 'Menu', superclass of Button
}
+ (id)buttonWithText:(NSString*)text atPosition:(CGPoint)position target:(id)target selector:(SEL)selector;
+ (id)buttonWithImage:(NSString*)file atPosition:(CGPoint)position target:(id)target selector:(SEL)selector;
@end
@interface ButtonItem : MenuItem { // !Cannot find interface declaration for 'MenuItem'...
Sprite *back; // !Unknown type name Sprite
Sprite *backPressed;
}
+ (id)buttonWithText:(NSString*)text target:(id)target selector:(SEL)selector;
+ (id)buttonWithImage:(NSString*)file target:(id)target selector:(SEL)selector;
- (id)initWithText:(NSString*)text target:(id)target selector:(SEL)selector;
- (id)initWithImage:(NSString*)file target:(id)target selector:(SEL)selector;
@end
改變一切到CCMenu,CCSprite不能解決問題。 Button.m中也有很多相關的錯誤
有沒有類似於Cocos2d 2.0的簡單按鈕的代碼?還是我錯過了明顯的東西?
我建議閱讀這個cocosbuilder教程http://code.zynga.com/2012/10/creating-a-game-with-cocosbuilder/它是繁瑣的佈局例程真的很棒的工具 – asdf
^他說了什麼。 – Clev3r