How do I load a new layout, then return to previous layout

Get help using Construct 2

Post » Sun Sep 11, 2016 6:42 pm

This may be an easy question for most of you- but I am still a noob in a lot of ways! I apologize if this has been answered before.

Question is- If I want to load a new layout at a point in my current layout- use the new one for a bit then return to the previous one from the exact same point- is there a way to do that? Ive tried saving and loading... but that erases everything that was done previously and its like you never did any of it- all global variables are reset to their values at the point of save for example.

Simple usage of what I am talking about- top down RPG style game, you walk up to a video game console / arcade machine- use it- and you load another game from another layout. Snake for example. In the main game you get some achievement if you play for X amount of time or reach X score- so I want to keep track of that stuff. When the arcade mini-game layout closes I want to be exactly where I was prior with just the variables affected that keep track of these things.

This is just an example of what I am trying to do- How would you recommend going about something like this? What if my game has multiple instances of this? Ive found lengthy ways around it which is a pain but works- such as setting another variable telling the game that it was last at the video game console, so if it loads that layout with that value true it puts you there- written out like this it doesnt seam like a big deal but it gets tedious when Im doing it so many times. Is there a better way?

Thanks!
B
14
S
5
G
6
Posts: 65
Reputation: 4,245

Post » Sun Sep 11, 2016 6:57 pm

In terms of player location on the machine, so it doesn't start from the original game load point, I store player x,y in a global variable when you leave the layout and set player position to these variables when returning to the layout.

In terms of global variables, they should all be saved if you have 'included' them on each event sheet so that they are used. Even when switching between layouts they are global so should remain the same. Also make sure you don't have any random reset global variable actions in there.
B
46
S
16
G
73
Posts: 2,082
Reputation: 43,673

Post » Sun Sep 11, 2016 7:42 pm

great advice- thanks
B
14
S
5
G
6
Posts: 65
Reputation: 4,245

Post » Tue Sep 13, 2016 9:44 pm

I have a followup question if anybody could share some thoughts-

Im using a tile-map as a fog-of-war type discovered undiscovered area- its easy enough to remember my X and Y, but is there a way to get the tile map to retain its tile data as well?

here is what im talking about:
Image

So if I put the guy in the same spot after an encounter- going in a town or whatever... how do I retain the tile map info? Can you save its current state? I havnt tried yet so it may be easy... im just at work and not looking at it but had this thought. Thanks-
B
14
S
5
G
6
Posts: 65
Reputation: 4,245

Post » Tue Sep 13, 2016 9:47 pm

You might want to check out the persist behavior.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Tue Sep 13, 2016 9:53 pm

Tokinsom wrote:You might want to check out the persist behavior.


haha thanks- if its something really simple and straight forward I apologize- I haven't messed with tilemaps much (obviously) ill check that out
B
14
S
5
G
6
Posts: 65
Reputation: 4,245


Return to How do I....?

Who is online

Users browsing this forum: Laura_D and 21 guests