How can I move an icon on a map?

0 favourites
  • 5 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • To select levels in the mobile version, the player selected by touching the screen.

    But how can I make the icon move from left to right, or from top to bottom with the keyboard?

    Thank you.

  • If you need free movement use the 8 directions or custom movement behaviors.

    If you want it to go the next/previous hotspot, add column and rows variables on the hotspots and on the player's object.

    Add/subtract from that on the player object based on the key press, then pick the hotspot based on those values and move it there.

    If you want it to walk down a certain path you can use path finding, otherwise just move it manually with the X and Y or with the moveto behavior.

  • You can also pick the nearest icon. For example:

    On Up key pressed
    Icon compare Y<CursorSprite.Y
    Icon Pick nearest to (CursorSprite.x, CursorSprite.y-20)
    

    It works best when all icons are placed on a grid. With a map like on your screenshot it may require a lot of tweaking.

    Another option is to add 4 instance variables to icons and use them to configure where the cursor will jump to from each icon. It will be a lot of manual work though.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm afraid it will be hard work...

  • You can use a combination of both methods. (this is what I do in our project) Pick by nearest, but if the cursor doesn't jump where you want - specify the destination icon in its instance variable.

    So on key pressed, you first check if there is a value in the variable. If there is, pick that destination icon. If there isn't, pick the nearest.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)