Hi all. As the title said it, I'm trying to make my character to be on the last position of it was after switching back and forth of the layout.
For example, I talked, one of the NPC, then it will bring me to the "Teaching" layout. Then after I'm done with the layout, it will be on the last position but that did not happen. I did tried to make it once, but it brings me to the initial character position on start of the "School" layout. I'm still new on this position thing.
Here is my .capx:
Develop games in your browser. Powerful, performant & highly capable.
Can't view your capx as I'm on mobile - but I would add two global variables to store your position. Call them something like 'ReturnToX' and 'ReturnToY'. Before switching layouts, set the global variables to the player's X and Y. After switching back, set the player's X and Y to the contents of the variables. This will allow you to always recall the player to their position before the last transition *only*.
To recall more than one transition, you might want to add a Dictionary object. When the player leaves a layout, add a key to the dictionary named Player.LayerName, with the value Player.X&","&Player.Y. When the player enters a layout, set their X to int( tokenat( Dictionary.Get( Player.LayerName ), 0, "," ) ) and their Y to int( tokenat( Dictionary.Get( Player.LayerName ), 1, "," ) ) . This will continually track the player's last location in as many layouts as you have, so long as all layouts have the necessary events. The Dictionary is a global object, so its contents are always available to all event sheets.
Thank you for your response. According to your suggestion, should I make my player sprite's name to be the same as my "Town" layout? Because each player character on each layout have different sprite name.
I would definitely try and make it so that the player was represented by the same sprite object everywhere they're present. You're lining yourself up for a headache.