简体   繁体   English

使图像视图向左移动

[英]Making image views move to the left

What I want is when I press START, the platforms will show, but they will move to the left as well.我想要的是当我按下 START 时,平台会显示,但它们也会向左移动。 So How can I do this?那么我该怎么做呢? Here is the code of what happens when we start the game:这是我们开始游戏时发生的代码:

-(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;
}

You do not want to create short duration timers and move your view objects by small increments each time your timer(s) fire.您不想创建持续时间较短的计时器并在每次计时器触发时以小增量移动您的视图对象。 You should look into UIView animation or CAAnimation objects.您应该查看 UIView 动画或 CAAnimation 对象。 I would suggest starting out with UIView animation methods that start with animateWithDuration .我建议从以animateWithDuration开头的 UIView 动画方法开始。 They are much easier to use than CAAnimation (Core Animation) which is complex, tricky, and not that well documented.它们比 CAAnimation(核心动画)更容易使用,CAAnimation 复杂、棘手且没有很好的文档记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM