Note that there are some explanatory texts on larger screens.

plurals
  1. POERROR: expected identifier or '(' in xcode ios 5
    primarykey
    data
    text
    <p>xcode 4.2 ios 5 single view template</p> <p>I am very new to this ios format and these new features in xcode </p> <p>Here is all of my code:</p> <pre><code>#import "SimpleGame2ViewController.h" #define kStateRunning 1 #define kStateGameOver 2 #define kLeftDown 1 #define kRightDown 2 #define kTouchesEnded 3 #define kPlatformWidth 55 #define kPlatformHeight 16 #define kMaxBallSpeed 10 #define kJumpPower 9 #define kGravity 0.195 @ implementation SimpleGame2ViewController @ synthesize ball; @synthesize platform1; @synthesize platform2; @synthesize platform3; @synthesize platform4; @synthesize platform5; @synthesize bg; @synthesize gameState; @synthesize ballVelocity, gravity; @synthesize touchState; -(void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle -(void)viewDidLoad { [super viewDidLoad]; gameState = kStateRunning; ballVelocity = CGPointMake(0, 0); gravity = CGPointMake(0, kGravity); [NSTimer scheduledTimerWithTimeInterval: 1.0 / 60 target: self selector: @selector(gameloop) userInfo: nil repeats:YES]; // Do any additional setup after loading the view, typically from a nib. } -(void)gameloop { if (gameState == kStateRunning) { [self gameStatePlayNormal]; } else if (gameState == kStateGameOver) { ballVelocity.x = 0; ballVelocity.y = 0; ball.center = CGPointMake(152 + 16, 326 + 16); platform1.center = CGPointMake(129 + (kPlatformWidth / 2), 414 + (kPlatformHeight / 2)); platform2.center = CGPointMake(34 + (kPlatformWidth / 2), 316 + (kPlatformHeight / 2)); platform3.center = CGPointMake(192 + (kPlatformWidth / 2), 261 + (kPlatformHeight / 2)); platform4.center = CGPointMake(146 + (kPlatformWidth / 2), 179 + (kPlatformHeight / 2)); platform5.center = CGPointMake(8 + (kPlatformWidth / 2), 81 + (kPlatformHeight / 2)); } } -(void)gameStatePlayNormal { ballVelocity.y += gravity.y; if (touchState == kLeftDown) { ballVelocity.x -= 0.2; } if (touchState == kRightDown) { ballVelocity.x += 0.2; } if (ballVelocity.x &gt; kMaxBallSpeed) { ballVelocity.x = kMaxBallSpeed; } if (ballVelocity.x &lt; -kMaxBallSpeed) { ballVelocity.x = -kMaxBallSpeed; } if (ball.center.x &gt; self.view.bounds.size.width) { ball.center = CGPointMake(0, ball.center.y); } if (ball.center.x &lt; 0) { ball.center = CGPointMake(self.view.bounds.size.width, ball.center.y); } ball.center = CGPointMake(ball.center.x + ballVelocity.x, ball.center.y + ballVelocity.y); if (ball.center.y &gt; self.view.bounds.size.height) { gameState = kStateGameOver; } } // Check for a bounce if (CGRectIntersectsRect(ball.frame, platform1.frame)) { if (ball.center.y + 8 &lt; platform1.center.y) { if (ballVelocity.y &gt; 0) { ballVelocity.y = -kJumpPower; } } } if (CGRectIntersectsRect(ball.frame, platform2.frame)) { if (ball.center.y + 8 &lt; platform2.center.y) { if (ballVelocity.y &gt; 0) { ballVelocity.y = -kJumpPower; } } } if (CGRectIntersectsRect(ball.frame, platform3.frame)) { if (ball.center.y + 8 &lt; platform3.center.y) { if (ballVelocity.y &gt; 0) { ballVelocity.y = -kJumpPower; } } } if (CGRectIntersectsRect(ball.frame, platform4.frame)) { if (ball.center.y + 8 &lt; platform4.center.y) { if (ballVelocity.y &gt; 0) { ballVelocity.y = -kJumpPower; } } } if (CGRectIntersectsRect(ball.frame, platform5.frame)) { if (ball.center.y + 8 &lt; platform5.center.y) { if (ballVelocity.y &gt; 0) { ballVelocity.y = -kJumpPower; } } } -(void)touchesBegan:(NSSet *) touches withEvent:(UIEvent *) event { if (gameState == kStateRunning) { UITouch *touch =[[event allTouches] anyObject]; CGPoint location =[touch locationInView:touch.view]; if (location.x &lt; (self.view.bounds.size.width / 2)) { touchState = kLeftDown; ballVelocity.x -= 0.2; } else { touchState = kRightDown; ballVelocity.x += 0.2; } } } -(void)touchesEnded:(NSSet *) touches withEvent:(UIEvent *) event { touchState = kTouchesEnded; } -(void)viewDidUnload { [self setBall:nil]; [self setPlatform1:nil]; [self setPlatform2:nil]; [self setPlatform3:nil]; [self setPlatform4:nil]; [self setPlatform5:nil]; [self setBg:nil]; [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } -(void)viewWillAppear:(BOOL) animated { [super viewWillAppear:animated]; } -(void)viewDidAppear:(BOOL) animated { [super viewDidAppear:animated]; } -(void)viewWillDisappear:(BOOL) animated { [super viewWillDisappear:animated]; } -(void)viewDidDisappear:(BOOL) animated { [super viewDidDisappear:animated]; } -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } @end </code></pre> <p>I have the error around </p> <pre><code>if (CGRectIntersectsRect(ball.frame, platform1.frame)) { if (ball.center.y + 8 &lt; platform1.center.y) { if (ballVelocity.y &gt; 0) { ballVelocity.y = -kJumpPower; } } } </code></pre> <p>I dont know why this is happening</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload