저는 cocos2d 2.0 및 Xcode 4.5를 사용합니다. 나는 선을 그리는 법을 배우려고 노력하고있다. 나는 선을 그릴 수는 있지만 몇 줄을 그린 후에는 Simulator에서 심각한 성능 문제가 발생합니다.Cocos2d ccDrawLine 성능 문제
시뮬레이터, 동결하기 시작 아주 아주 천천히 라인을 그리고 -(void)draw
는 매 프레임마다 호출의 화면에 레이블이 라인 전에 굵은
되기 때문에 모든 최악는 것 같아요 :
을
라인 이후.
나는 다음 코드를 사용합니다 하는 .m
-(id) init
{
if((self=[super init])) {
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Simple Line Demo" fontName:@"Marker Felt" fontSize:32];
label.position = ccp(240, 300);
[self addChild: label];
_naughtytoucharray =[[NSMutableArray alloc ] init];
self.isTouchEnabled = YES;
}
return self;
}
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
BOOL isTouching;
// determine if it's a touch you want, then return the result
return isTouching;
}
-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [ touches anyObject];
CGPoint new_location = [touch locationInView: [touch view]];
new_location = [[CCDirector sharedDirector] convertToGL:new_location];
CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation];
oldTouchLocation = [self convertToNodeSpace:oldTouchLocation];
// add my touches to the naughty touch array
[_naughtytoucharray addObject:NSStringFromCGPoint(new_location)];
[_naughtytoucharray addObject:NSStringFromCGPoint(oldTouchLocation)];
}
-(void)draw
{
[super draw];
ccDrawColor4F(1.0f, 0.0f, 0.0f, 100.0f);
for(int i = 0; i < [_naughtytoucharray count]; i+=2)
{
CGPoint start = CGPointFromString([_naughtytoucharray objectAtIndex:i]);
CGPoint end = CGPointFromString([_naughtytoucharray objectAtIndex:i+1]);
ccDrawLine(start, end);
}
}
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
ManageTraffic *line = [ManageTraffic node];
[self addChild: line z:99 tag:999];
}
나는 그런 비행 제어, ATC 매니아 정말 잘 작동 한 적은 수의 항공 교통 관제 게임을 보았다.
CCDrawLine/UITouch *touch
때문에이 성능 문제가 발생합니까? 아니면 일반적인 문제입니까? 무엇이 비행 제어, ATC Mania가 선 그리기에 사용 중일 수 있습니까?
미리 감사드립니다.
편집 :::: 나는 문제가 ccDrawLine없는 것 같다
OK, 문제는 내가이 장면을가는
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
ManageTraffic *line = [ManageTraffic node];
[self addChild: line z:99 tag:999];
}
시뮬레이터에서 성능을 실제로 판단 할 수 없습니다. 장치에서 테스트해야합니다. –