1
我使用繪圖函數來突出顯示插入到高分表中的分數,但是我發現當我嘗試離開高分層時,它使得我的應用程序滯後。我還是比較新的cocos2d
,所以我想知道是否有更好的方法,所以它不會造成任何滯後。我發現如果我註釋掉這個函數沒有任何滯後。下面是我的代碼:繪圖函數導致應用程序滯後
- (void)draw {
[super draw];
if(currentScorePosition < 0 || currentScore==0) return;
float w = 320.0f;
float h = 20.0f;
float x = (320.0f - w)/2.0f;
float y = 230.0f - currentScorePosition * h;
CGPoint vertices[4];
vertices[0] = ccp(x, y);
vertices[1] = ccp(x+w, y);
vertices[2] = ccp(x+w, y+h);
vertices[3] = ccp(x, y+h);
CCDrawNode *draw = [[[CCDrawNode alloc] init] autorelease];
[draw drawPolyWithVerts:vertices count:4 fillColor:ccc4f(0.5, 0.5, 0.8, 0.5) borderWidth:2.0 borderColor:ccc4f(0.0, 0.0, 0.0, 0.0)];
[self addChild:draw z:0 ];
}