////////////Template code //////////// Chunk 3 GameScene.m @interface GameScene () @property (strong, nonatomic) UITouch *leftPaddleMotivatingTouch; @property (strong, nonatomic) UITouch *rightPaddleMotivatingTouch; @end -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { /* Called when a touch begins */ for (UITouch *touch in touches) { CGPoint p = [touch locationInNode:self]; NSLog(@"\n%f %f %f %f",p.x,p.y,self.frame.size.width,self.frame.size.height); if (p.x < self.frame.size.width * 0.3) { self.leftPaddleMotivatingTouch = touch; NSLog(@"left"); } else if (p.x > self.frame.size.width * 0.7) { self.rightPaddleMotivatingTouch = touch; NSLog(@"right"); } else{ // Optionally speed up the ball for any other touch //SKNode *ball = [self childNodeWithName:@"ball"]; //ball.physicsBody.velocity = CGVectorMake(ball.physicsBody.velocity.dx*2.0, ball.physicsBody.velocity.dy); } } } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if ([touches containsObject:self.leftPaddleMotivatingTouch]) self.leftPaddleMotivatingTouch = nil; if ([touches containsObject:self.rightPaddleMotivatingTouch]) self.rightPaddleMotivatingTouch = nil; } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { if ([touches containsObject:self.leftPaddleMotivatingTouch]) self.leftPaddleMotivatingTouch = nil; if ([touches containsObject:self.rightPaddleMotivatingTouch]) self.rightPaddleMotivatingTouch = nil; }