Giroscopio iPad 1: balanceo, cabeceo, guiñada permanecen cero

I'm trying to make a simple app utilizing gyroscope, where a character moves according to the rotation of the iPad 1.

My code is not working, so I tested to see the values of raw,pitch,yaw, and they actually stay as zero however I move the device. I'm sure iPad 1 supports CMMotionManager, so I'm not sure what's causing it... My code is as follows

- (id) init{
if((self=[super init])){
    self.isTouchEnabled = YES;
    winSize = [[CCDirector sharedDirector] winSize];
    [self createRabbitSprite];

    self.motionManager = [[CMMotionManager alloc] init];
    motionManager.deviceMotionUpdateInterval = 1.0/60.0;
        [motionManager startDeviceMotionUpdates];
    [self scheduleUpdate];
    //[self registerWithTouchDispatcher];
return self;


CMDeviceMotion *currentDeviceMotion = motionManager.deviceMotion;
CMAttitude *currentAttitude = currentDeviceMotion.attitude;

    [currentAttitude multiplyByInverseOfAttitude:referenceFrame];

float roll = currentAttitude.roll;
float pitch = currentAttitude.pitch;
float yaw = currentAttitude.yaw;

NSLog(@"%.2f and %.2f and %.2f",roll,pitch,yaw);

rabbit.rotation = CC_RADIANS_TO_DEGREES(yaw);


Please help me out.. and thanx in advance.


Apparently, motionManager.isDeviceMotionAvailable is returning FALSE... which must mean that iPad 1 doesn't support CoreMotion??? Could it be something with the setting?

preguntado el 27 de agosto de 11 a las 16:08

You may refer to this answer: -

1 Respuestas

The iPad First generation does support CMMotionManager (as it has an accelerometer), but won't return any gyroscopic data - it doesn't have a gyroscope! You'll need to check the gyroAvailable propiedad de un CMMotionManager ejemplo.

Respondido 27 ago 11, 20:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.