Create a Sliding Puzzle Without Arrays

4
  • 11 favourites

Attached Files

The following files have been attached to this tutorial:

.capx

scirra-slider2.capx

Download now 3.68 MB

Stats

4,951 visits, 7,287 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Play the game here:

https://www.scirra.com/arcade/puzzle-games/scirra-slider-puzzle-includes-capx-download-2124

I like sliding puzzles and they have many uses as a standalone game or as a puzzle within a larger game.

You can use arrays to create these but it is more complicated so I came up with a simple slider puzzle that uses a place holder for the empty slot and just switches the sprite that is overlapping that place holder.

You need a couple of global variable to hold the clicked puzzle piece X and Y coordinates so you can set the place holder to that coordinate.

NOTE: Pay special attention to the polygon collision detector used for the place holder empty slot.

The place holder polygon is diamond shaped roughly so only the corners that would overlap the puzzle pieces are in contact with the place holder.

That prevents any overlap from the puzzle piece that is on a diagonal from the place holder from moving by mistake.

I included a 9 piece graph you can use to design your own puzzles. You can make this game with more pieces if you wish to.

The CAPX has all the comments to explain how it works and the game is in the arcade so please come by and give it a try and leave a rating.

-LaMar

.CAPX

scirra-slider2.capx

Download now 3.68 MB
  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!