<error>:CGAffineTransformInvert:奇异矩阵错误</error>

时间:2014-09-27 02:03:39

标签: ios objective-c iphone xcode6

我收到错误:CGAffineTransformInvert:每次运行我的应用程序时出现奇异矩阵错误,但我不知道导致问题的原因。代码如下,请有人帮助我。任何回答的人我都提前感谢。

    #import "Squirrel.h"
      @interface Squirrel ()

      @end

   @implementation Squirrel

 -(void)Scoring{
ScoreNumber = ScoreNumber + AddedScore;
AddedScore = AddedScore - 1;

if (AddedScore < 0){
    AddedScore = 0;
}

Score.text=[NSString stringWithFormat:@"Score: %i", ScoreNumber];
} 

 -(void)Gameover{

Acorn1.hidden=YES;
Branch1.hidden=YES;

}

-(void)Losing{

if(CGRectContainsRect(Sammy.frame, Acorn1.frame)){
    AddedScore=1;
    RandomPosition=arc4random()%248;
    RandomPosition=RandomPosition+36;
    Acorn1.center=CGPointMake(RandomPosition, 88);
      }
if(CGRectContainsRect(Sammy.frame, Acorn2.frame)){
    AddedScore=1;
    /*RandomPosition=arc4random()%248;
    RandomPosition=RandomPosition+36;
    Acorn2.center=CGPointMake(RandomPosition, 56);*/

 }
if(CGRectContainsRect(Sammy.frame, Acorn3.frame)){
    AddedScore=1;
}
if(CGRectContainsRect(Sammy.frame, Branch1.frame)){
    //[self Gameover];
    AddedScore=1;
}



}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{

SquirrelLeft=NO;
SquirrelRight=NO;
StopSideMovement=YES;
 }

 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self.view];

if(point.x < 160){

    SquirrelLeft=YES;
}

else{

    SquirrelRight=YES;
}
      }
            -(void)moving{

Sammy.center = CGPointMake(Sammy.center.x + SideMovement, 366);

if(Acorn1.center.y > 463){
    RandomPosition = arc4random() %248;
    RandomPosition = RandomPosition + 36;
    Acorn1.center = CGPointMake(RandomPosition, 16);
}
if(Acorn2.center.y > 463){
    RandomPosition = arc4random() %248;
    RandomPosition = RandomPosition + 36;
    Acorn2.center = CGPointMake(RandomPosition, 16);
}
if(Acorn3.center.y > 463){
    RandomPosition = arc4random() %248;
    RandomPosition = RandomPosition + 36;
    Acorn3.center = CGPointMake(RandomPosition, 16);
}
if(Branch1.center.y > 463){
    RandomPosition = arc4random() %248;
    RandomPosition = RandomPosition + 36;
    Branch1.center = CGPointMake(RandomPosition, 16);
}
if(Branch2.center.y > 463){
    RandomPosition = arc4random() %248;
    RandomPosition = RandomPosition + 36;
    Branch2.center = CGPointMake(RandomPosition, 16);
}
if(Branch3.center.y > 463){
    RandomPosition = arc4random() %248;
    RandomPosition = RandomPosition + 36;
    Branch3.center = CGPointMake(RandomPosition, 16);
}
if(Branch4.center.y > 463){
    RandomPosition = arc4random() %248;
    RandomPosition = RandomPosition + 36;
    Branch4.center = CGPointMake(RandomPosition, 16);
}

if(SquirrelLeft == YES){

    SideMovement = SideMovement-0.8;
    if(SideMovement < -5){
        SideMovement = -5;
    }
}

if(SquirrelRight ==YES){
    SideMovement = SideMovement + 0.8;
    if(SideMovement > 5){
        SideMovement = 5;
    }
}

if(StopSideMovement == YES && SideMovement>0){
    SideMovement = SideMovement - 0.1;
    if (SideMovement < 0){
        SideMovement = 0;
        StopSideMovement=NO;
    }
}

if (StopSideMovement == YES && SideMovement<0){
    SideMovement=SideMovement+0.1;

    if(SideMovement>0){
        SideMovement=0;
        StopSideMovement=NO;
    }
}
if(AddedScore == 1 && CGRectContainsRect(Sammy.frame, Acorn1.frame)){

    Branch1.center = CGPointMake(Branch1.center.x, Branch1.center.y + 6);
    Branch2.center = CGPointMake(Branch2.center.x, Branch2.center.y + 6);
    Branch3.center = CGPointMake(Branch3.center.x, Branch3.center.y + 6);
    Branch4.center = CGPointMake(Branch4.center.x, Branch4.center.y + 6);
    Acorn2.center = CGPointMake(Acorn2.center.x, Acorn2.center.y + 5);
    Acorn3.center = CGPointMake(Acorn3.center.x, Acorn3.center.y + 5);
}
  }

  -(void)moveBranch1{

Branch1.center = CGPointMake(Branch1.center.x, Branch1.center.y + 6);

 }
     -(void)moveBranch2{

Branch2.center = CGPointMake(Branch2.center.x, Branch2.center.y + 6);

 }
      -(void)moveBranch3{

Branch3.center = CGPointMake(Branch3.center.x, Branch3.center.y + 6);

 } 
   -(void)moveBranch4{

Branch4.center = CGPointMake(Branch4.center.x, Branch4.center.y + 6);
     }

   -(void)moveAcorn1{

Acorn1.center = CGPointMake(Acorn1.center.x, Acorn1.center.y + 5);
 }

      -(void)moveAcorn2{

Acorn2.center = CGPointMake(Acorn2.center.x, Acorn2.center.y + 5);
    }
   -(void)moveAcorn3{

Acorn3.center = CGPointMake(Acorn3.center.x, Acorn3.center.y + 5);
    }

   - (IBAction)Start:(id)sender {

Acorn1.hidden=NO;
Acorn2.hidden=NO;
Acorn3.hidden=NO;
Branch1.hidden=NO;
Branch2.hidden=NO;
Branch3.hidden=NO;
Branch4.hidden=NO;

Title.hidden=YES;
Mu.hidden=YES;
Main.hidden=YES;
Start.hidden=YES;
HighScore.hidden=YES;
How.hidden=YES;

MoveAcorn1 = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveAcorn1) userInfo:nil repeats:YES];
MoveAcorn2 = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveAcorn2) userInfo:nil repeats:YES];
MoveAcorn3 = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveAcorn3) userInfo:nil repeats:YES];
MoveBranch1 = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveBranch1) userInfo:nil repeats:YES];
MoveBranch2 = [NSTimer scheduledTimerWithTimeInterval:0.09 target:self selector:@selector(moveBranch2) userInfo:nil repeats:YES];
MoveBranch3 = [NSTimer scheduledTimerWithTimeInterval:0.09 target:self selector:@selector(moveBranch3) userInfo:nil repeats:YES];
MoveBranch4 = [NSTimer scheduledTimerWithTimeInterval:0.09 target:self selector:@selector(moveBranch4) userInfo:nil repeats:YES];
Moving = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moving) userInfo:nil repeats:YES];
losing = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(Losing) userInfo:nil repeats:YES];
Scoring = [NSTimer scheduledTimerWithTimeInterval:0.00000001 target:self selector:@selector(Scoring) userInfo:nil repeats:YES];

RandomPosition=arc4random()%248;
RandomPosition=RandomPosition+36;
Acorn1.center=CGPointMake(RandomPosition, 88);

RandomPosition=arc4random()%248;
RandomPosition=RandomPosition+36;
Acorn2.center=CGPointMake(RandomPosition, 56);

RandomPosition=arc4random()%248;
RandomPosition=RandomPosition+36;
Acorn3.center=CGPointMake(RandomPosition, 22);

RandomPosition=arc4random()%248;
RandomPosition=RandomPosition+36;
Branch1.center=CGPointMake(RandomPosition, 35);

RandomPosition=arc4random()%248;
RandomPosition=RandomPosition+36;
Branch2.center=CGPointMake(RandomPosition, 25);

RandomPosition=arc4random()%248;
RandomPosition=RandomPosition+36;
Branch3.center=CGPointMake(RandomPosition, 77);

RandomPosition=arc4random()%248;
RandomPosition=RandomPosition+36;
Branch4.center=CGPointMake(RandomPosition, 43);


         }

 - (void)viewDidLoad {

Acorn1.hidden=YES;
Acorn2.hidden=YES;
Acorn3.hidden=YES;
Branch1.hidden=YES;
Branch2.hidden=YES;
Branch3.hidden=YES;
Branch4.hidden=YES;

[super viewDidLoad];       

0 个答案:

没有答案
相关问题