Well, it makes sense that it's returning to it's normal position since you're updating the rotation constantly. If you call rightJoystick.autoCenter = FALSE; when you first create the joyStick, does that sort of solve your problem?
Looking over the source for JoyStick, it seems odd that there's no isActive variable that you could refer to. I guess it would be easy enough to add -
In SneakyJoystick.h:
@interface SneakyJoystick : CCNode <CCTargetedTouchDelegate> {
...
BOOL isActive;
}
@property (readwrite, assign, nonatomic) BOOL isActive;
...
Now synthesize it in SneakyJoystick.m:
@synthesize
...
deadRadius,
isActive;
In SneakyJoystick.m, in the -initWithRect: method, under self.deadRadius = 0.0f;:
self.isActive = FALSE;
Under the ccTouchBegan:event: method, before the method returns YES:
if(joystickRadiusSq > dSq){
[self updateVelocity:location];
self.isActive = TRUE;
return YES;
}
and finally at the start of ccTouchEnded:event: method:
self.isActive = FALSE;
Then just change your code:
//interval:1.0f/120.0f
-(void)mainGameLoop:(float)delta {
if (rightJoystick.isActive) {
player.rotation = -rightJoystick.degrees;
}
}
I think that will work, though I haven't tested it...
Chris