Remember player position when changing layout

0 favourites
  • 5 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hi!

    I have two layouts, main and shop.

    When player enters the shop from the main layout, and then again exits the shop, the position of the player resets to the beginning of the main layout.

    I tried to set the position in the event sheet of the shop like this:

    button-->on clicked-->player sprite-->set position to (4000,1000);

    system-->go to main layout;

    That didn't work; the location of the player still resets to the beginning of the level.

    How could I make the player appear outside the shop door when he exists?

  • I show this in my platform tutorial (going in a tunnel and coming out) but basically like this.

    Variables:

    isShop = 0

    playerX =0

    playerY = 0

    Just before the event to change to the shop layout set:

    isShop = 1

    playerX = Player.X

    playerY = Player.Y (Player is whatever the name of your player object is).

    Then on start of layout for the main layout create a sub event:

    If isShop = 1

         Set Player Position = playerX and playerY

         Set isShop = 0

    Something like that :). Then you a have that sub event for other changes that take effect after leaving the shop.

  • You can add the Persist Behavior to objects to have then remember where they were (they don't get destroyed when the layout ends and then recreated when you go back to the layout).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would do as ArcadeEd suggested, just pass the info through a global variable and recall it.

  • Persist behavior should be enough... but the porblem its all the other element like enemies... bullets ect...

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