我正在为滚动视图绘制 52 个标签、精灵和按钮。但是,当我滚动时,当我使用滚动视图时,它会非常滞后。我使用类似的设置,在 x 和轴上滚动,没有延迟。我正在 iphone 5 上进行测试,所以我认为它能够非常轻松地处理它。对象需要移动的距离被正确计算并且对象被正确绘制它只是真的滞后。绘制代码:
int cnt = 40;
for (NSString *i in [Trucks GetSetTruckList].TruckList){
NSMutableArray *Truck = [[NSMutableArray alloc] initWithArray:[TruckDict objectForKey:i]];
CGSize s = [[CCDirector sharedDirector] winSize];
CCMenuItemImage *BuyButton = [CCMenuItemImage itemWithNormalImage:@"Buy.jpg" selectedImage:@"Buy.jpg"block:^(id sender) {[self BuyTruck:Truck]; }];
BuyButton.position = ccp((s.width/2) - 20 , (s.height/2) - cnt + ShopPointX);
BuyButton.scale = .5;
CCLabelTTF *Name = [CCLabelTTF labelWithString:[Truck objectAtIndex:0] fontName:@"Marker Felt" fontSize:19];
Name.position = ccp(100, (s.height) - cnt + ShopPointX);
CCLabelTTF *NumPeople = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"Ppl: %@" , [Truck objectAtIndex:2]] fontName:@"Marker Felt" fontSize:13];
NumPeople.position = ccp(200, (s.height) - cnt + ShopPointX);
CCLabelTTF *NumCrate = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"Crgo: %@" , [Truck objectAtIndex:1]] fontName:@"Marker Felt" fontSize:13];
NumCrate.position = ccp(270, (s.height) - cnt + ShopPointX);
CCSprite *Pic = [CCSprite spriteWithFile:[Truck objectAtIndex:5]];
Pic.position = ccp(340, (s.height) - cnt + ShopPointX);
Pic.scale = .3;
CCMenu *Menu = [CCMenu menuWithItems:BuyButton, nil];
cnt = cnt + 40;
[self addChild:Pic];
[self addChild:Menu];
[self addChild:Name];
[self addChild:NumCrate];
[self addChild:NumPeople];
StartShop = 1;
}