我正在爲滾動視圖繪製52個標籤,精靈和按鈕。但是,當我去滾動它是非常滯後的,當我使用滾動視圖。我使用了一個類似的設置,可以在沒有延遲的x和軸上滾動。我正在測試iPhone 5,所以我認爲它可以很容易地處理它。物體需要移動的距離正在被正確計算,並且物體正在被正確地繪製,它實際上是滯後的。繪製代碼:當繪製精靈時Cocos 2D大FPS下降
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;
}
我沒有使用UIScrollView。 – 2013-03-23 21:41:46