Build 10 classic Flash games and learn game development along the way with this ultra-fast paced game development course.

If you love this blog, this is the book for you.

Buy the book

Get the source code of 12 commercial Flash games, which have been loaded more than 50 million times!

Learn from real world successful examples.

Get it now

Box2D for Flash Games teaches you how to make Flash physics games from scratch with the most advanced features.

Create the new Flash game smashing hit.

Buy the book

Dungeon Raid iPhone game engine made with Flash and AS3

An iPhone game which I enjoyed a lot last year, a great twist in the “match three” genre, was Dungeon Raid.

Tracing a path and matching tiles you will be able to collect treasures, buy and upgrade weapons and defeat monsters.

In this post I am going to cover the part which traces a path along tiles. While it may seem easy, there are a couple of interesting things to consider:

1) Your path can be traced in diagonal, and this means you have to define hot spots on the tiles which must be smaller than the tile itself, or you surely touch adjacent horizontal and vertical tiles before you touch diagonal ones.

2) You can backtrack through the path, but you can’t walk over already other previously selected tiles. This will require a vector to be used as a stack to manage backtracking.

I made a fully commented script, where Tile and Path are the two movieclips representing respectively the tile (frame 1: unselected, frame 2: selected) and the path (frame 1 to 8: west, north-west, north, north-east and so on in clockwise order).

The darker circle inside tiles is the hot spot.

Enjoy the result:

Select tiles and move the mouse to draw a path and eventually backtrack it.

Download the source code

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 5.00 out of 5)
Loading ... Loading ...
Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 6 comments

  1. Bruno

    on July 10, 2012 at 8:44 pm

    There seems to be a slightly problem.

    Here is a pic:
    http://desmond.imageshack.us/Himg580/scaled.php?server=580&filename=bugmhl.jpg&res=landing

    I dont know exactly how I did this, but I was trying to cross paths.

  2. Bojan

    on July 11, 2012 at 1:17 am

    Found a bug, if you select few squares and then stop in last (for example, mouse button is down all the time) and move a mouse in that square a bit then release a mouse and game will not clear squares, they stay selected.

    Do you plan part 2 of this tutorial?

  3. Bojan

    on July 11, 2012 at 1:21 am

    Edit: You need to go forward and back few times between two or more fields to recreate this bug, it does not show all the time but it can be done pretty often.

  4. pp

    on July 11, 2012 at 3:53 am

    seem when i try to make diagonal and longer lines,
    then back tracking then make false back tracking diagonal and released mouse
    then circles is not reset

  5. Ervin

    on July 11, 2012 at 9:58 pm

    Anyway it’s a very interesting post. Thank you.

  6. Husky

    on July 17, 2012 at 7:59 am

    Wow!
    I love this game too,
    Thanks for your sharing.