A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Tile by Tile movement?

  1. #1
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976

    Tile by Tile movement?

    At the monent my tile based game has pixel by pixel movment. Which means my character moves at 3 pixels per frame. But what i want to know how to do is. Tile by tile movement. Like in Final Fantasy 6 where you press the direction you want to move in and the character moves at 3 pixels per frame tile it reaches the the center of the tile in the direction pressed.

    Any help would be most appretiated.

    Thanks in Advance

  2. #2
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    well that is not difficult for example if you tiles are 18x18 then you can move the sprite 2 times with step of 9 (9+9=18) or 9 times with step of 2 or 3 times with step of 6, or 6 times with step of 3 you can do this as follows:

    in the hero movie clip:
    1. get the keypress and direction of move with onClipEvent (enterFrame). It is important to get this direction only if the the _currantframe==1 for example:

    Code:
    onClipEvent (enterFrame){
    if (this._currantframe==1){
    
    if (Key.isDown (Key.RIGHT)){dir="right";}
    
    }}
    2. frame 1: stop()
    3. frame2:

    Code:
    count+=step;
    if ( dir == "left"){this._x-=step;} else
    if ( dir == "right"){this._x+=step;} else
    if ( dir == "up"){this._y-=step;} else
    if ( dir == "down"){this._y+=step;}
    4. frame 3:

    Code:
    if ( count >=18){
    count=0;
    this.gotoAndStop(1);}
    else{
    gotoAndPlay (2);
    }

    hope that helps. the variable step could be 2,6,3,9

    ms

  3. #3
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks Mad-Sci looks like it will solve my prob.

    ThankS again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center