Hey guys
My game requires the user to control a sprite being rotated around a hole. I had it so that when the user tilted left, it would spin clock wise, and when tilted right, counter-clockwise. But from feedback, the better approach would be to tilt according to which ever way you want the sprite to rotate to. Ex: If user wanted sprite rotated to the top of circle, they would tilt up, and the sprite would start moving the top, regardless of which side of the circle it was coming from.
I've tried a few things but no dice... here's what I have:
- (CGPoint) RotateAroundPt:(CGPoint)centerPt withAngle:(float)radAngle withRadius:(float)radius {
float x = centerPt.x + cosf(radAngle) * radius;
float y = centerPt.y + sinf(radAngle) * radius;
CGPoint spritec = ccp(x,y);
return spritec;
}
tick method
circleAngle += accelX;
newSpritePos = [self RotateAroundPt:circleCenter withAngle:circleAngle withRadius:circleRadius];
playerSprite.position = ccp( newSpritePos.x , newSpritePos.y );
in accelermeter
CGPoint converted = ccp( (float)-acceleration.y, (float)acceleration.x);
static float prevX=0;
accelX = converted.x * kFilterFactor + (1- kFilterFactor)*prevX;