嗨有人可以向我解釋使用sprite kit冒險遊戲中的接口,從蘋果。精靈套件中的接口冒險遊戲
他們有一個叫做APAMultiplayerLayeredCharacterScene
主類和承接來自這個叫做APAAdventureScene
另一個類。
在APAMultiplayerLayeredCharacterScene
他們有一堆的.H屬性看起來像這樣:
@interface APAMultiplayerLayeredCharacterScene : SKScene
@property (nonatomic, readonly) NSArray *players; // array of player objects or NSNull for no player
@property (nonatomic, readonly) APAPlayer *defaultPlayer; // player '1' controlled by keyboard/touch
@property (nonatomic, readonly) SKNode *world; // root node to which all game renderables are attached
@property (nonatomic) CGPoint defaultSpawnPoint; // the point at which heroes are spawned
@property (nonatomic) BOOL worldMovedForUpdate; // indicates the world moved before or during the current update
@property (nonatomic, readonly) NSArray *heroes; // all heroes in the game
現在在.m文件他們有這樣的:
@interface APAMultiplayerLayeredCharacterScene()
@property (nonatomic) NSMutableArray *players; // array of player objects or NSNull for no player
@property (nonatomic) APAPlayer *defaultPlayer; // player '1' controlled by keyboard/touch
@property (nonatomic) SKNode *world; // root node to which all game renderables are attached
@property (nonatomic) NSMutableArray *layers; // different layer nodes within the world
@property (nonatomic, readwrite) NSMutableArray *heroes;// our fearless adventurers
@property (nonatomic) NSArray *hudAvatars; // keep track of the various nodes for the HUD
@property (nonatomic) NSArray *hudLabels; // - there are always 'kNumPlayers' instances in each array
@property (nonatomic) NSArray *hudScores;
@property (nonatomic) NSArray *hudLifeHeartArrays; // an array of NSArrays of life hearts
@property (nonatomic) NSTimeInterval lastUpdateTimeInterval; // the previous update: loop time interval
@end
@implementation APAMultiplayerLayeredCharacterScene
有人能解釋我使用這兩組屬性,哪些屬性被類使用,哪些屬性可以從繼承它的類中訪問?
我很困惑它是如何工作的,因爲這些屬性都不合成,所以我不明白他們爲什麼被使用。我從來沒有以這種方式使用過它們。
非常感謝!
感謝您清理這個問題,他們是否必須在.M中定義爲實現細節,還是僅僅是「最佳實踐」? – dev6546
這是最佳做法。代碼中的重要區別是'()'(vs':SKScene')。 –
謝謝,我現在將閱讀那篇文章。 – dev6546