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

Create a Flash Game like Nano War

Some days ago I played a bit Nano War.

Nano War

It’s an interesting RTS, and pretty easy to delvelop.

In this part we’ll analyze the unit selection system.

In Nano War your units are circles, and this helps a lot because it’s very easy to determine collisions knowing radius and center.

Anyway, you can select units in these ways:

Click on an unselected unit: you select the unit

Click on an selected unit: you keep selecting the unit (good!)

Click outside an unit: you deselect all units

Click outside an unit and drag mouse: you select all units whose center is inside the shape you are drawing bby dragging the mouse.

In this example, 10 units are randomly placed around the screen, avoiding them to overlap.

Then, you can select and deselect them in the way explained before.

Units are made by a circle object linked as “sphere” with two frames: frame 1 is a black circle and represents the unit when deselected, while frame 2 is a red circle and represents the unit when selected.

Now, a little commented actionscript:

And this is the result… easy to play… just select unit clicking on them or dragging.

Deselect by clicking elsewhere.

I would like to spend two words on beginFill() that I never covered on the blog…

beginFill() indicates the beginning of a new drawing path. If an open path exists and it has a fill associated with it, that path is closed with a line and then filled.

During next part we’ll manage unit invasion.

Meanwhile download the source code.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (23 votes, average: 3.78 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 13 comments

  1. Xodus

    on August 6, 2008 at 4:59 am

    Hey, im really excited about this game concept, i cant wait for the next tut. Good post.

    Btw, i suddenly noticed that you dont have the line “if you liked this post, you can buy me a beer (or two)” Why did you take it off?

  2. Questo

    on August 6, 2008 at 5:18 am

    maybe you can fix a small bug that doesn’t matter thats in the actual game:

    If you have a unit selected while it is taken over it still has a line coming out of it (it can’t shoot or do anything for you anything but still)

  3. FrozenHaddock

    on August 6, 2008 at 6:52 am

    Oh, nice.

    I played this, a lot. I was -hoooooked-

    I look forward to the rest of this.

  4. Mr Sun

    on August 6, 2008 at 2:00 pm

    Thanks for the tutorial :)
    I always wondered how I could do a selection sort of thing in actionscript

  5. Gabriel Bianconi

    on August 6, 2008 at 5:44 pm

    Great Tut!

  6. JDog

    on August 6, 2008 at 7:22 pm

    Looks good !

  7. samedi

    on August 11, 2008 at 6:12 am

    this game is a similar one with a twist
    http://www.newgrounds.com/portal/view/449961

    i like both ones… like tic tac toe on steroids
    My problem with these games are that after you have found the right strategy its impossibles to loose.

    I think explaining how to create an AI for a game like this would be a great tutorial

  8. badben

    on August 11, 2008 at 7:23 pm

    Hi,
    I’m surprised to see my game on this website :).

    Regards.

  9. Flash Tutorials | AS3, AS2 Flash game tutorials roundup part 2 | Lemlinh.com

    on August 23, 2008 at 5:09 am

    [...] Read more [...]

  10. Flash obstacle avoidance prototype : Emanuele Feronato

    on August 25, 2008 at 4:29 pm

    [...] the project there are 20 random obstacles placed in the same way as seen on Create a Flash Game like Nano War, and an object linked as runner running through [...]

  11. cssdesigner

    on August 29, 2008 at 2:00 pm

    Wow I make this step-by-step and I played with it!

    Nice tutorial!

  12. Actionscript tutorial for RTS/Strategy Flash Game | PencilGym.com

    on September 27, 2009 at 5:54 am

    [...] Have a deeper read over at the source article: http://www.emanueleferonato.com/2008/08/05/create-a-flash-game-like-nano-war/#more-381 [...]

  13. future systemz

    on February 28, 2010 at 11:06 am

    Where the next tutorial?