Puzzle Slider

cnmeyer1980cnmeyer1980 Member, PRO Posts: 211
edited November -1 in Working with GS (Mac)
Hi guys,

Just wondering if anyone can advise on the below.

I'm trying to work out how to make a basic slide puzzle (3 rows by 3 rows) and I've really no idea where to start to be honest - I've done a search on the web but cant unfortunately find any video or web tutorials.

If anyone can shine any light on this, that would be great,

Cheers,

Chris

Comments

  • LBGLBG Member Posts: 277
    Hi,

    I have one of these in my game. I used some code that is on the forum somewhere for a pairs card game. If you search you should be able to find it. I think it was a guy called Wayne that made it. That piece of code will allow you to randomly generate your puzzle pieces (you will need to make some edits to it as his code is for a puzzle game with 4x4 cards).

    Once this is in place you need a way to slide the pieces once you tap. Create an actor called border and place it around the 4 edges of your puzzle. Then create new actors called puzzleTouch and puzzleDetect. You need to set up the rules so that when you tap on a puzzle piece it spawns puzzleTouch at the centre of the piece you tapped. This in turn spawns 4 puzzleDetect actors at x,y co-ordinates equal to the width/height of your pieces plus any margins between them. For example, your puzzle pieces are 60x60 and there is a 10 pixel gap between them. You want the puzzleDetect actor to be spawned at puzzleTouch x - 70 for left side (I know that isn't real code). Do this for north, east, south and west positions. The puzzleDetect actor needs as set of rules that say 'if I don't collide with anything save my position to a sharedAttribute. You also now need a rule on your puzzle piece to say when I am tapped, for xseconds change privateattribute selfTapped to true. You can then say that if the puzzle piece is tapped and the xy attributes on the sharedxyAttribute are greater than 0, change self.positionx&y to these xy attributes. I then had to create a rule that said when all puzzle pieces are in their final position you win.

    I hope I haven't confused you too much. I'm new to all this and it took me a while to get this to work but it does work. It may also not be the best approach but others may be able to help more. I'm currently typing this on my iPhone so sorry for lack of grammar and punctuation. Let me know if I can help any more.

    LBG
  • LBGLBG Member Posts: 277
    After reading the post through I realised there are some pieces missing. When I have a moment I'll go through it and edit it some more. The idea is there though so I hope it helps a bit.

    LBG
  • cnmeyer1980cnmeyer1980 Member, PRO Posts: 211
    Hi mate,

    Thank you so much for this, and also, typing all that out on your iPhone! blimey!!!

    I will go though all this this evening and see what I manage to work out.

    Many thanks,

    Chris
Sign In or Register to comment.