gpt4 book ai didi

ios - 冒险游戏 Sprite 套件中的界面

转载 作者:行者123 更新时间:2023-11-29 03:27:36 25 4
gpt4 key购买 nike

您好,有人可以向我解释一下 Apple 的 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

有人可以向我解释这两组属性的用途吗?哪些属性由类使用,哪些属性可以从继承它的类访问?

我对它的工作原理感到困惑,因为这些属性都没有被合成,所以我不明白为什么要使用它们。我以前从未以这种方式使用过它们。

非常感谢!

最佳答案

Can someone explain to me the uses of both of these sets of properties, which properties are used by the class and which ones can be accessed from classes that inherit from it?

这称为“类扩展”。 接口(interface) (.h) 中的属性允许被其他类修改。您应该忽略实现 (.m) 中的属性 - 它们是实现细节。

更多 info on class extensions here .

none of these properties are synthesised so I don't understand why they are being used

属性不再需要合成。如果您省略了 @sythnesize 语句,它会在编译时为您添加。 Here's a good blog post关于这个话题。

关于ios - 冒险游戏 Sprite 套件中的界面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20255619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com