0
有沒有什麼辦法可以讓CCSprite像汽車轉向一樣?如果我用CCSprite釋放我的觸摸,它應該像轉向一樣順利地自動返回到原來的位置!進出口使用下面的代碼,CCSprite旋轉像Cocos2D中的汽車轉向
-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch=[touches anyObject];
//acquire the previous touch location
CGPoint firstLocation = [touch previousLocationInView:[touch view]];
location = [touch locationInView:[touch view]];
CGPoint touchingPoint = [[CCDirector sharedDirector] convertToGL:location];
CGPoint firstTouchingPoint = [[CCDirector sharedDirector] convertToGL:firstLocation];
CGPoint firstVector = ccpSub(firstTouchingPoint, Steering.position);
CGFloat firstRotateAngle = -ccpToAngle(firstVector);
CGFloat previousTouch = CC_RADIANS_TO_DEGREES(firstRotateAngle);
CGPoint vector = ccpSub(touchingPoint, Steering.position);
CGFloat rotateAngle = -ccpToAngle(vector);
CGFloat currentTouch = CC_RADIANS_TO_DEGREES(rotateAngle);
dialrotation+=currentTouch-PreviousTouch;
sprite.rotation=dialrotation;
}
這種平穩轉動我的CCSprite,但我不知道如何要返回到它像汽車Steering.Is有原來的位置任何方式在cocos2d這樣做呢?