CCNode のサブクラスである "Button" クラスがあります。ボタン (コンピューターのボタンなど) は CCLabelBMFont または CCSprite ではないため、CCNode としてサブクラス化しました。さらに、CCLabelBMFont を子 "CCLabelCustom" で拡張しました。これには独自の凝ったロジックがあります。そこで、CCLabelCustom *buttonLabel と CCSprite *buttonSprite を「ボタン」の iVar として移動しました。デフォルトのbuttonLabelまたはbuttonSpriteを使用せずに、「ボタン」をできるだけ抽象的にしたいと考えています。問題は、CCLabelCustom と CCSprite の両方を開始するにはどうすればよいですか? CCLabelCustom には、5 つ以上のパラメーターを持つ長い初期化がいくつかあり、追加のプロパティを割り当てることができます。
// Rough Idea to help elaborate my classes
@interface Button : CCNode
@property (nonatomic, strong) CCLabelCustom *buttonLabel;
@property (nonatomic, strong) CCSprite *buttonSprite;
@end
// Rough Idea to help elaborate my classes
@interface CCLabelCustom : CCLabelBMFont
@property (nonatomic, strong) SomeProperty *someVar;
@property (nonatomic, strong) AnotherProperty *anotherVar;
-(void)fancyMethod;
-(void)initWithSomething:(Something*)something andAnother:(Another*)another alongWith:(Fun*)fun;
@end
私が知らないアーキテクチャはありますか?クラス外から2つのiVarで「ボタン」を初期化できる方法はありますか? 「ボタン」クラス内で定義できるデフォルト値は必要ありません。外層からやりたい。前もって感謝します。