How to replace images in a puzzle game

I am making my first game as a simple puzzle game.

i mew in the game program.

i put image 4 in the view to assign them images, cropping one original image with 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 viewing position of the image in the view, I use 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 I need that ever one kind of image approaches another representation of the image, then I need to exchange my positions.

for example: part1 go through part2, then part2 to place1 of part one and part1 to place part2.

How can I do this, can someone help me.

This is the right approach to make this puzzle.

Thanks in advance.

+1
source share
1 answer

Well, since you use images, you need to implement collision detection logic in your project. try some of the codes at http://apress.com/book/downloadfile/4587 . he has very good examples of collision detection, and he is free.

and try reading this game development book on iphone

http://apress.com/book/view/9781430225997

Greetings

+2
source

Source: https://habr.com/ru/post/1336255/


All Articles