Create Actor On Scene Switch

JeffreyDriver

  • Posts: 1830
I have some code that creates the player actor in the next scene depending on which direction the new scene is approached. For example, if leaving a scene from the top, the actor will appear at the bottom of the next scene. However, this will only work if the actors which trigger the switch are positioned at the edges of the game area.

If I want to create the player actor somewhere else than the edge of the game area, well, I've run into trouble. Maybe I've just been looking at this too long, but I can't figure it out, at least in a way that doesn't mean I have to manually create the coords for each individual scene.
Current Projects:
Retro Redux Compilation (NEW).
Retro Redux (untitled) (NEW).
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

Luyren

  • *
  • Posts: 1508
Attached is part of my Change Scene behavior for a side-scroller platformer. Look at that "Create Actor at Next Scene" if statement.
The "get item 0 from split Next Scene Coordinates with ," is how I store the coordinates to the next scene in one attribute. 0 gets the X position, 1 gets the Y position. It's a text attribute, and its format is X,Y, for example 10,15.
-If the height of the region is bigger than its width, it is a horizontal transfer (left to right). It will create the actor with its center at the X position in the next scene, and its Y position proportional to the distance between the bottom of the actor and the bottom of the region.
-If the width of the reion is bigger than its height, it is a vertical transfer (top to bottom). It will create the actor with its bottom at the Y position in the next scene, and its X position proportional to the distance of the left side of the actor and the left side of the region.

If I understood your issue correctly, this should solve it. You can recreate the image attached in Sencyl (ignoring the parts that are irrelevant to your game, such as the game attribute) if my explanation didn't make sense. Or I can draw an explanation if that is confusing, if you need it.
Working.

JeffreyDriver

  • Posts: 1830
Thanks Luyren. I'll try implementing it later on.
Current Projects:
Retro Redux Compilation (NEW).
Retro Redux (untitled) (NEW).
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

Luyren

  • *
  • Posts: 1508
I forgot to mention this in my previous comment: in a horizontal transfer, the "next scene coordinates" is the position on the ground for your actor on the next scene, or the lowest most position for the bottom of your actor. In a vertical transfer, "next scene coordinates" is the leftmost position for your actor on the new scene.
Working.