- (void)addBackground{
CGSize winSize = [CCDirector sharedDirector].winSize;
float maxReach = 0;
//Loop 3 times
for (int loopTimes = 0; loopTimes < 2; loopTimes++) {
//Add images to batchNode
for (int imageNumber=1; imageNumber < 13; imageNumber++) {
CCSprite *background = [CCSprite spriteWithFile:[NSString stringWithFormat:@"national_scenery_part%d.png",imageNumber]];
background.position = ccp((winSize.width/2)+maxReach, winSize.height/2);
[self addChild:background z:0];
maxReach = maxReach + background.contentSize.width;
}
//Ends loopTimes loop
}
}
Image #7显示为一个细长的矩形,大约是其原始大小的1/4 。