2
我想在科科斯2d手指畫線。科科斯2d畫線不工作
-(void) ccTouchesMoved:(NSSet *)inappropriateTouches withEvent:(UIEvent *)event
{
UITouch *touch = [inappropriateTouches anyObject];
CGPoint currentTouchArea = [touch locationInView:[touch view] ];
CGPoint lastTouchArea = [touch previousLocationInView:[touch view]];
currentTouchArea = [[CCDirector sharedDirector] convertToGL:currentTouchArea];
lastTouchArea = [[CCDirector sharedDirector] convertToGL:lastTouchArea];
// throw to console my inappropriate touches
NSLog(@"current x=%2f,y=%2f",currentTouchArea.x, currentTouchArea.y);
NSLog(@"last x=%2f,y=%2f",lastTouchArea.x, lastTouchArea.y);
glColor4f(0.8, 1.0, 0.76, 1.0);
glLineWidth(6.0f);
ccDrawLine(currentTouchArea, lastTouchArea);
}
我使用此代碼,但沒有任何東西在屏幕上繪製。我的代碼有什麼問題?
它的工作原理,但爲什麼當繪製新舊的一行被刪除? –
因爲每次刷新它都會清除屏幕。要堅持這些線條,您將不得不存儲一組點以表示您希望繪製的線條。 –