i am doing my first game like simple puzzle game.
i an mew to gaming program.
i place a 4 image view in the view assign images to them by cropping one original image using this code.
int partId = 0;
for (int x=0; x<=200; x+=100) {
for(int y=0; y<=200; y+=100) {
CGImageRef cgImg = CGImageCreateWithImageInRect(whole.CGImage, CGRectMake(x, y, 100, 100));
UIImage* part = [UIImage imageWithCGImage:cgImg];
to get the image view position in the view i am using this code
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
// get touch event
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
NSLog(@"%f %f",touchLocation.x,touchLocation.y);
Now what i need to when ever one image view comes near to the another image view then i need to exchange their positions.
eg: part1 come over part2 then part2 in the place1 of part one and part1 in the place of part2.
How can i done this can any one please help me.
Is this is correct approach to do this puzzle game.
Thank u in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…