Scene switching problem

Right now I am making a top-down legend of Zelda like game and am facing a problem with the scene switching (Keep in mind I am new at this.)  So to give an example of my problem lets say this.  When you start the game you start in a field.  Then you walk over to a house.  When you are inside the house every thing works fine and dandy.  But then once you exit the house you spawn back out in the field instead of in front of the door.  So I get that you have to put in coordinates to where you want the actor to show up.  But I can't figure out how to to do that.  Anyway if you know then please help. ;)

froz

  • Posts: 250
I would add 2 games attributes. One for storing x coordinate, another for y coordinate. Let's call them here Xgame, Ygame.

What you want to do is:
- do not set the actor on manually (in the scene), but do it via code
- in the second scene, when actor is leaving, you need to set Xgame, Ygame to proper values (those would be x/y of position where you want the actor to appear in the first scene)
- in the first scene, make a scene behaviour that "when created" creates your hero at Xgame, Ygame. The little bit tricky part is to make it also work when you first start the game. Assuming you have some kind of menu scene, you would need to set Xgame, Ygame when player press "start game" or something similar, before the menu scene goes away and first scene is loaded.


That's how I would do it, but keep in mind I'm not an expert.

Photon

  • Posts: 2691
There actually is a block that can tell the next scene where to spawn the actor. I believe it is under Scene >> Game Flow? It's somewhere in Scene on the behavior palette, I know that much. I'm not in front of Stencyl right now, so I can't check.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!