使图像视图向左移动

时间:2015-10-23 23:01:36

标签: ios objective-c

我想要的是当我按下START时,平台会显示,但它们也会向左移动。那我该怎么办呢?以下是我们开始游戏时会发生什么的代码:

-(IBAction)Start:(id)sender{
    Start.hidden = YES;
    Exit.hidden = YES;
    HighScoreLabel.hidden = NO;
    Heli.hidden = NO;
    PowerUp.hidden = NO;

    Obstacle1.hidden = NO;
    Obstacle2.hidden = NO;
    Platform1.hidden = NO;
    Platform2.hidden = NO;
    Platform3.hidden = NO;
    Platform4.hidden = NO;

    Trap1Cactus1.hidden = NO;
    Trap1Cactus2.hidden = NO;
    Trap2Saw1.hidden = NO;
    Trap2Saw2.hidden = NO;

    WinOrLose.hidden = YES;
    Top.hidden = YES;
    Bottom.hidden = NO;

    TrapUpsideDown.hidden = NO;
    TrapUpsideDown2.hidden = NO;
    SuperJump.hidden = NO;

    SavedFromDeathLabel.hidden = NO;
    ExplosionIfSaved.hidden = NO;

    BirdMovement = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(ShipMoving) userInfo:nil repeats:YES];


    HigherJump = [NSTimer scheduledTimerWithTimeInterval:0.07 target:self selector:@selector(SuperJumping) userInfo:nil repeats:YES];

    HighTrap.hidden = NO;
}

1 个答案:

答案 0 :(得分:0)

每次定时器触发时,您都不希望创建持续时间较短的定时器并以较小的增量移动视图对象。您应该查看UIView动画或CAAnimation对象。我建议从以animateWithDuration开头的UIView动画方法开始。它们比CAAnimation(核心动画)更容易使用,CAAnimation是复杂的,棘手的,并且没有很好的文档记录。