-2

-(void) awakeaccelerometer の 2 番目の関数 -(void) accelerometer から randX と randY を使用しようとしています。プログラムはそれらを認識できません。前もって感謝します。

-(void) awakeaccelerometer
{
    [[UIAccelerometer sharedAccelerometer]setUpdateInterval:1.0/50.0];
    [[UIAccelerometer sharedAccelerometer]setDelegate:self];

    float randX = arc4random() % 320;
    float randY = arc4random() % 548;

    CGPoint randNewPlace = CGPointMake(randX, randY);
    Rand.center = randNewPlace;

}


//Controlling the accelerometer
-(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
.....

CGRect blockRect = CGRectMake(newX, newY, 20, 20);
CGRect targetRect = CGRectMake(randX, randY, 20, 20);

    if (CGRectIntersectsRect(blockRect, targetRect))
    {
        float tnewX = arc4random() % 320;
        float tnewY = arc4random() % 548;

        CGPoint randNewPl = CGPointMake(tnewX, tnewY);
        Rand.center = randNewPl;
    }


}
4

1 に答える 1