Switch back to a scene where you left off

ogm2710

  • Posts: 9
Hey
I've made a game, where my character is going in to a shop half way through a level. After you are done shopping, i want my character to go back where he left off, but I don't know how to do that, and I can't find it any where online. Can anyone plz help me?

JeffreyDriver

  • Posts: 2262
There's a couple of main ways to do this. Firstly, you can store all the values you need, such as the players X & Y values, and simply recall those when you switch back. You'll need to get to grips with attributes to be able to do this.

Another option is to have the shop there on the same scene, but hide it when you don't need it. This might not be suitable if your shop is really complex though, but I'm doing something similar where a journal and inventory slide on and off the screen as needed.

ogm2710

  • Posts: 9
There's a couple of main ways to do this. Firstly, you can store all the values you need, such as the players X & Y values, and simply recall those when you switch back. You'll need to get to grips with attributes to be able to do this.

Another option is to have the shop there on the same scene, but hide it when you don't need it. This might not be suitable if your shop is really complex though, but I'm doing something similar where a journal and inventory slide on and off the screen as needed.
But if I use the first method, will all the other actors i have killed  spawn again.

batuhancan

  • Posts: 150
They will, if you first save into (list) attributes which actor type, coordinates and any other info you need for the actors.
Essentially, you first want to make a behaviour which collects the data before switching scenes. When switching back you'll need a behaviour than can take the data and spawn your actors from it.

ogm2710

  • Posts: 9
They will, if you first save into (list) attributes which actor type, coordinates and any other info you need for the actors.
Essentially, you first want to make a behaviour which collects the data before switching scenes. When switching back you'll need a behaviour than can take the data and spawn your actors from it.
And how do I do the exactly?

batuhancan

  • Posts: 150
First determine what data will be needed for your game. How many variable actors in the scene are we talking? Do they change coordinates? How different can the scene become while playing, from how it started?

ogm2710

  • Posts: 9
I can walk around and collect coins and kill monsters. It dosen't matter where the monsters are exactly.

BMJ

  • Posts: 278
For switching to a shop inside another scene, I *highly* recommend you simply make the shop in a different part of the scene (somewhere it can be neither reached nor seen) and "teleport" your player actor to it. You can use an image or background layer or even an actor (put in the foreground) to make a transitional "fade to black" effect (or any other effect) before the teleporting happens. This way all the actors will not be deleted & recreated. You can either freeze them or let them keep simulating. If performance is an issue, freeze them. (Actually, you may want to freeze them no matter what - otherwise your player might take unfair damage as they leave the shop and there is an enemy in front of the door where there wasn't one when s/he entered.) This is so so so so so so much easier than recording all the x/y data of every actor currently alive in the scene and then recreating them when leaving the shop. That is really not worth the effort unless you actually need it.

« Last Edit: November 15, 2016, 11:15:23 am by BMJ »

ceosol

  • *
  • Posts: 2279
ogm, from your other questions, it looks like you are trying to make a game beyond your current capabilities. I would suggest making little prototype games with one or two base mechanics until you learn more about how Stencyl functions.

ogm2710

  • Posts: 9
For switching to a shop inside another scene, I *highly* recommend you simply make the shop in a different part of the scene (somewhere it can be neither reached nor seen) and "teleport" your player actor to it. You can use an image or background layer or even an actor (put in the foreground) to make a transitional "fade to black" effect (or any other effect) before the teleporting happens. This way all the actors will not be deleted & recreated. You can either freeze them or let them keep simulating. If performance is an issue, freeze them. (Actually, you may want to freeze them no matter what - otherwise your player might take unfair damage as they leave the shop and there is an enemy in front of the door where there wasn't one when s/he entered.) This is so so so so so so much easier than recording all the x/y data of every actor currently alive in the scene and then recreating them when leaving the shop. That is really not worth the effort unless you actually need it.
I'm just gonna do that then, thank you :D