1

新しい迷路ゲームに D-Pad を実装しようと何度も試みましたが、うまくいきません。私は 4 つの UIButton のスタイルでそれを行っています。1 つを押すと、別の画像が上下左右に移動します。Quartzcore と CAAnimation を使用してみましたが、限られたコードしか知りません。

メソッドとボタンを宣言しましたが、動作するものをコーディングできません。

やっていた:

-(IBAction)Up:(id)sender{

CGPoint origin1 = self.Player.center;
CGPoint target1 = CGPointMake(self.Player.center.x, self.Player.center.y-124);
CABasicAnimation *bounce1 = [CABasicAnimation animationWithKeyPath:@"position.y"];
bounce1.duration = 0.1;
bounce1.fromValue = [NSNumber numberWithInt:origin1.y];
bounce1.toValue = [NSNumber numberWithInt:target1.y];
[self.Player.layer addAnimation:bounce1 forKey:@"position"];

}

ゴーストは下に移動しますが、すぐに跳ね返ります。私は何時間も困惑しており、顔が睨まれているかもしれませんが、私の愚かさを理解してください.

4

1 に答える 1