How do I make my game remember the player's map positition?

0 favourites
  • 6 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • So, in my game I have a map screen, Mario Bros 3 style, where the player moves on a grid from level to level like so:

    The problem I'm having is that I don't know how to make the game remember what level the player is at once they enter it. If the player, say, goes to level 2 and completes it, the game puts them back on the level 1 square when they leave the level and go back to the map because that's the default position. How do I make it so that the game remembers the player's position on the map screen?

  • Add a global variable called 'level' or something, whenever the user moves between levels update the value appropriately. Whenever the map is opened, move the player to the level stored in the 'level' variable.

  • I'm not entirely sure how to do that but I think I'm halfway there. In order for the game to know what level the player will be going to, I have a global variable called 'atLevel' which is set whenever the player box object overlaps one of the level "buttons" like so:

    How can I make it so that the game sets the player to the button that has the corresponding 'atLevel' value? Like if level 2's 'atLevel' value is 2, how would I set the player there coming out of a level? I don't have to do 'System > atLevel = 2 > Playerbox_Map > Set position to level2button' etc. for every level button do I? Is there a more condensed way to do it?

  • The method you described would work and yes there is a more condensed way. I would personally have all of the level buttons as one sprite, and create multiple instances of it. Then the sprite has an instance variable called 'level'. Give the sprite an animation with every level icon, but set the animation to not play. Make each frame of the animation correspond to the instance variable. Then you can loop through all instances of this sprite to see which one has the corresponding level. See attached capx.

    [attachment=0:2u4o5o2h][/attachment:2u4o5o2h]

  • Ah, thank you, this works nicely. I appreciate the help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • snipped, I figure it warrants its own thread so I made one for it

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