EXC_BAD_ACCESS code=1 to EXC_BREAKPOINT in main.m
I've been searching the web (mostly this site) for answers to this
question. I have found some relative questions, all of which didn't work
for me or were not answered themselves. I am writing a simple pong
program, where right now I have the main load screen with a button that
brings you to the game screen. On the game screen is a button that is
meant to start the ball moving by using an NSTimer.
GameComputerVSPlayer.h
#import <UIKit/UIKit.h>
int x;
int y;
@interface GameComputerVSPlayer : UIViewController {
IBOutlet UIImageView *backcolor;
IBOutlet UIImageView *ball;
IBOutlet UIImageView *computerPaddleVert;
IBOutlet UIImageView *computerPaddle;
IBOutlet UIImageView *playerPaddleVert;
IBOutlet UIImageView *playerPaddle;
IBOutlet UIImageView *cornerTL;
IBOutlet UIImageView *cornerTR;
IBOutlet UIImageView *cornerBL;
IBOutlet UIImageView *cornerBR;
IBOutlet UIButton *startButton;
NSTimer *timer;
}
@property (nonatomic, retain) UIImageView *ball;
@property (nonatomic, retain) UIImageView *computerPaddleVert;
@property (nonatomic, retain) UIImageView *computerPaddle;
@property (nonatomic, retain) UIImageView *playerPaddleVert;
@property (nonatomic, retain) UIImageView *playerPaddle;
-(IBAction)nextPoint:(id)sender;
-(void)ballMovement;
@end
GameComputerVSPlayer.m
#import "GameComputerVSPlayer.h"
#import "ViewController.h"
@interface GameComputerVSPlayer ()
@end
@implementation GameComputerVSPlayer
@synthesize ball, playerPaddleVert, playerPaddle, computerPaddleVert,
computerPaddle;
-(void)ballMovement {
ball.center = CGPointMake(ball.center.x + x, ball.center.y + y);
}
-(IBAction)nextPoint:(id)sender{
timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self
selector:@selector(ballMovement) userInfo:nil repeats:YES];
x = arc4random()%9;
x = x - 5;
y = arc4random()%9;
y = y - 5;
if (y==0) {
y = 1;
}
if (x==0) {
x = 1;
}
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle
*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
I have also tried to use NSZombie as well, but that hadn't shown me
anything. Thanks in advance for your work!
No comments:
Post a Comment