我試圖讓'luke'跳過一個對象來確保遊戲不會結束,他會這樣做,但即使他避免了遊戲仍然結束的對象,就好像luke還沒有離開他在動畫期間的原始位置。Collision detection&animateWithDuration
我在-(void)touchesBegin
中使用了UIView animateWithDuration來試圖實現這一點。
[UIView animateWithDuration:3
animations:^
{
luke.center = CGPointMake(luke.center.x +0, luke.center.y -60);
}
completion:^(BOOL completed)
{
if (completed)
{
[UIView animateWithDuration:3
animations:^
{
luke.center = CGPointMake(luke.center.x +0, luke.center.y +60);
}];
}
我也使用CGRectIntersectsRect
告訴我,當兩個物體發生碰撞
-(void)collision {
if (CGRectIntersectsRect(luke.frame, smallboulder.frame)) {
[self endgame];
}
if (CGRectIntersectsRect(luke.frame, largeboulder.frame)) {
[self endgame];
}
if (CGRectIntersectsRect(luke.frame, cactus.frame)) {
[self endgame];
}
終於我可以使用動畫設置爲NSArray
跳時表現出的運動。
非常感謝
JP
爲什麼你使用這種過時的Xcode版本? –
我正在使用一個macbook4.1,我不能升級雪豹以上。因此過時的版本 – user3369583
你有更現代的PC嗎?您可以將小牛安裝在虛擬機中並開展工作。 –