0

我是新来的,我应该用两个球编写一个游戏,第一个由用户控制,第二个应该编程。我不知道如何确保第二个球阻止用户的球?我是一个中间人。你能帮助我吗。我有一个代码要更改:`CGRect tableRect = self.view.bounds; CGRectenemyRect = self.enemy.frame;

if (CGRectGetMinX(enemyRect)<CGRectGetMinX(tableRect) ||
    CGRectGetMaxX(enemyRect)>CGRectGetMaxX(tableRect)) {
    playerValue++;
    playerlabel.text = [NSString stringWithFormat: @"%d", playerValue];
    enemylabel.text = [NSString stringWithFormat: @"%d", enemyValue];
    moveX = -moveX;

}
if (CGRectGetMinY(enemyRect)<CGRectGetMinY(tableRect) ||
    CGRectGetMaxY(enemyRect)>CGRectGetMaxY(tableRect)) {
    playerValue++;
    playerlabel.text = [NSString stringWithFormat: @"%d", playerValue];
    enemylabel.text = [NSString stringWithFormat: @"%d", enemyValue];
    moveY = -moveY;
}
CGPoint center = enemy.center;
center.x += moveX;
center.y += moveY;
enemy.center = center;
[self performSelector:@selector(move) withObject:nil afterDelay:timerIntervale];


if (CGRectIntersectsRect(enemyRect, player.frame)) {
    CGRect frame = [player frame];
    frame.origin.x = 137.0f;
    frame.origin.y = 326.0;
    [player setFrame:frame];

    CGRect frame2 = [enemy frame];
    frame2.origin.x = 137.0f;
    frame2.origin.y = 20.0;
    [enemy setFrame:frame2];
    enemyValue++;
    playerlabel.text = [NSString stringWithFormat: @"%d", playerValue];
    enemylabel.text = [NSString stringWithFormat: @"%d", enemyValue];

}`

我想知道我是否更改代码或添加行。非常感谢你帮助我。

添加游戏

4

1 回答 1

1
enemy.userInteractionEnabled = NO;
于 2012-04-22T09:18:21.913 回答