Hi guys what I am trying to do is to create 6 sprites and to space them out evenly, I edited some code i got from a book, but am currently stuck at the part where I need to space the sprites out evenly
[groundNode setPosition:CGPointMake(45, 20)];
where this will stack all 6 sprites on top of each other? How can I make it in such a way it would become something like
[groundNode setPosition:CGPointMake(45*x, 20)];
where x is the int taken from the for loop. My code is listed at the bottom. Thank you so much!!
-(id)init{
self = [super init];
if(self !=nil){
for(int x=0;x<6;x++){
[self createGround];
}
}
return self;
}
-(void) createGround{
int randomGround = arc4random()%3+1;
NSString *groundName = [NSString stringWithFormat:@"ground%d.png", randomGround];
CCSprite *groundSprite = [CCSprite spriteWithFile:groundName];
[self addChild:groundSprite];
[self resetGround:groundSprite];
}
-(void) resetGround:(id)node{
CGSize screenSize =[CCDirector sharedDirector].winSize;
CCNode *groundNode = (CCNode*)node;
[groundNode setPosition:CGPointMake(45, 20)];
}