Making Actors Appear in the Correct Position

Skillism

  • Posts: 61
Hi,

So I've created a top down scene, Zelda style, which has the player attached. When he enters a region it changes scene and in the new scene, when he enter's it's region he comes back to the original scene.

My question is this. How do you make the actor appear next to the region when the scene changes, instead of where he's been attached in the scene.

At a super basic level so will need a very detailed explanation of which blocks to use and how to use them.

Any help would be much appreciated. Many thanks

Regards

Mark

Bombini

  • *
  • Posts: 1371
Hi Mark,
i hope i understood right (see image):



Lets assume that the star is your starting position.
You want to set the player to to an arrow depending on where he/she came from right (scene)?

What i would do:

  • Create a game attribute (number).
  • Set the number one when starting in scene 1.
  • When you go to another scene: Check the number (this way the game knows where you come from) and set the player to coordinates you define (x,y, the arrows in the example).  You could also move the player to the coordinates of an invisible actor (ignore that if it confuises you)
  • Change the number of the game attribute to the scene number afterwards.
Hope that helps!

Skillism

  • Posts: 61
The image shows exactly what I'm trying to do. Ok so first I should click on Settings at the top of the window to create a game attribute (number). Then in scene 1 , on the left I should click on +Add Event and then go to Attributes and then Number.  Am still lost, like I said, am not familiar with Stencyl or any kind of game development software. Sorry about that. So how eactly should I accomplish what you're describing?

Bombini

  • *
  • Posts: 1371
It is actually very simple.
The question is if a Zelda game is too complex if you havent done any kind of game development before.
I am pretty sure. Try something simpler first.

Anyway. Here is a code that works.
Try to rebuild it and understand. Works like you envisoned it.



Skillism

  • Posts: 61
Not trying anything as complicated as Zelda, just using the same view.  Excellent! Many thanks. Much appreciated.

Skillism

  • Posts: 61
Actually sorry, forgot to mention, scene 1 has a long tile width, with entrances to many different  scenes as the scene scrolls. I understand the logic you've posted and will definitely use it in the other scenes but for the starting scene, what logic would be correct to allow the player to enter one of the many different scenes from the original scene and then to return in the correct position. Hope that makes sense.

jguarShark

  • Posts: 80
I do not mean this rudely at all, but I'd recommend you follow some tutorials before trying to create your game. These questions are basic enough that you will be spending a large amount of time on the forums asking people to write the logic for you, when you could follow a tutorial and learn to do it yourself instead.

I highly recommend Learning Stencyl 3.x Game Development: Beginner's Guide [url]. It took me from total noob to fairly accomplished, in a surprisingly short time.

Wishing you lots of luck.

Innes

  • *
  • Posts: 1961
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

Skillism

  • Posts: 61
It's a great book, bought it for my kindle. Very clear and easy to follow. I got to the chapter on Animation and then decided to try something out on Stencyl in a flash of inspiration. Just to recap though, if the first scene has a long tile width with many doors leading to different scenes, how do you get the player to appear in the correct position when they return to the original scene and without the player being duplicated?

letmethink

  • *
  • Posts: 2545
You don't place the player in the scene using the scene designer initially.
~Letmethink

Bombini

  • *
  • Posts: 1371
Sigh...try something simpler first and do some tutorials. The answer is already there ;)

Skillism

  • Posts: 61
Have been doing the tutorials in the book. And guessing from your reply, the screen shot you uploaded explains not just how to set the position in a new scene but when returning to the original scene, how to appear in front of any number of possible doors? Many thanks for your patience. I have a whole day on Wednesday to try and get it working :)

Bombini

  • *
  • Posts: 1371
Have been doing the tutorials in the book. And guessing from your reply, the screen shot you uploaded explains not just how to set the position in a new scene but when returning to the original scene, how to appear in front of any number of possible doors? Many thanks for your patience. I have a whole day on Wednesday to try and get it working :)

The code i posted lets the player appear where ever you want (setting the x and y).  The game "knows" from which scene the player comes from because the code sets the attribute "scene number" in the visited scene before.

This means that you can have 5 doors in your first scene leading to 5 scenes and you set the player infront of the right door when coming back. Using the same logic as i did.

Put this code in every sceen (adjusting the coordinates and scene numbers obviously).
Have in your first scene something like: if scene number 1 set player to ... , if scene number 2 set player to ... ,

You can place the player wher ever you want in the design mode. The code will move it anyway.
Cheers!

« Last Edit: November 12, 2014, 01:38:52 am by Bombini »

Skillism

  • Posts: 61
Thanks Bombini. You've been extremely helpful!  Much appreciated :)

Skillism

  • Posts: 61
It's working! Thanks again :)