I could really do with some help here. I’ve spent the past couple of hours trying to work out how to compare the value of a CGPoint and the center property of an image. I had assumed the two values were in the form of x and y coordinates. Below is the code i have written.
-(void) jigsawCompleted:(CGPoint) newcenter {
if(image1.center == newcenter &&
image2.center == newcenter &&
image3.center == newcenter &&
image4.center == newcenter) {
NSLog(@"success");
}
}
.......
.......
//if current touch is inside the rectangle
if (CGRectContainsPoint(snapToRect, location)) {
touch.view.alpha = 1.0;
//make a point with the coords below
CGPoint newcenter = CGPointMake(78, 382);
//assign the center coords of the current touch to this newly created point
touch.view.center = newcenter;
[self jigsawCompleted:newcenter];
return;
} else {
touch.view.alpha = 0.3;
}
When comparing the two values in the jigsawCompleted method i get the error: Invalid operands to binary expression (‘CGpoint’ (aka ‘struct CGPoint’) and ‘CGPoint’).
Any help please?
Use
CGPointEqualToPoint().