droit essentiellement ce que Ive a obtenu est une application qui est une boule et chauve-souris et son nombre de rebonds que vous pouvez réaliser, il fonctionne bien, mais il y a un problème,iPhone SDK aide avec mini-jeu
lorsque la balle frappe le côté de la chauve-souris, il jette son cours et son comme le cadre de la balle rebondit dans le cadre de la chauve-souris, voici mon code dans mon mainview.m
#import "MainView.h"
#define kGameStateRunning 1
@implementation MainView
@synthesize paddle, ball;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
CGPoint xLocation = CGPointMake(location.x,paddle.center.y);
paddle.center = xLocation;
}
-(IBAction) play {
pos = CGPointMake(14.0,7.0);
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
}
-(void) onTimer {
ball.center = CGPointMake(ball.center.x+pos.x,ball.center.y+pos.y);
if(ball.center.x > 320 || ball.center.x < 0)
pos.x = -pos.x;
if(ball.center.y > 460 || ball.center.y < 0)
pos.y = -pos.y;
[self checkCollision];
}
-(void) checkCollision {
if(CGRectIntersectsRect(ball.frame,paddle.frame)) {
pos.y = -pos.y;
}
}
@end
quelqu'un peut-il travailler le problème ici? Merci Harry