如何访问精灵数组中的单个精灵?

How to access single sprite in array of sprites?

如何访问精灵数组中的第一个精灵并将其位置更改为此?

        sprite.position = CGPointMake(arc4random_uniform(self.frame.size.width), arc4random_uniform(self.frame.size.height));

@property (nonatomic, strong) SKSpriteNode *aSprite;
@property (nonatomic) NSMutableArray *sprites;

一个用于精灵一数组来容纳它们

要访问精灵数组中的第一个对象,您可以这样做:

SKSpriteNode *object = [myArray firstObject];
object.position = CGPointMake(arc4random_uniform(self.frame.size.width), arc4random_uniform(self.frame.size.height));

要访问数组中的所有对象,请执行以下操作:

for(SKSpriteNode *object in myArray) {
    object.position = CGPointMake(arc4random_uniform(self.frame.size.width), arc4random_uniform(self.frame.size.height));
}