Continuing in Isometrics: A hero stepping on a tile

February 1st, 2010 by Brian Leave a reply »

We started with this great game engine and we edited the arrays to add walls at different locations on the map. This week we’re going to add a custom floor tile that:

  • Checks to see if the hero is standing on the tile.
  • If the hero is on the tile, sends the entire Flash timeline to the next frame.

First let’s make sure we know how to recognize the hero stepping on a tile.

  1. Open up your project file from last week. (Remember: the original file can be found here if you were gone.)
  2. Open up the project’s library.
  3. Right-click/CTRL+click on the ’tile100′ movie clip in the library. Choose ‘Duplicate’.
  4. Name it ’tile101′. Make sure to click the checkbox next to Linkage: Export for ActionScript.
  5. Double-click the ’tile101′ movie clip to edit it. Double-click the square and select a new color from the paintbucket for it.
  6. Click on Scene 1 to go back to the main timeline.
  7. Click on the frame with all the ActionScript in it. To edit the ActionScript, click on the arrow in the frame’s Properties window.
  8. Look for the code that reads:

    _root.onEnterFrame = function():Void
    {
    input(); // Handle keyboard movement
    return;

    };
    Let’s add a message that pops up, showing that the exit was stepped on. We’ll use the trace function for that:
    _root.onEnterFrame = function():Void
    {
    input(); // Handle keyboard movement
    if(canvas.map[hero.y][hero.x] == 101) trace("Exit");
    return;

    };

    A message should pop up in the debugger window with the word “Exit” showing up while you step on the tile.

    Now that we can tell if the tile is being stepped on, see if you can figure out how to send the hero to a new map.

Advertisement

Leave a Reply