Control can only be pressed when in certain range?

Jedinator

  • Posts: 20
Hello, I would like to add a behavior (to a scene?) that would limit the player from pressing a control until he is a in a certain range.  If you suggestions, I would love to hear them. Thanks!

Innes

  • *
  • Posts: 1960
There are several ways to achieve this, but can you explain exactly what you mean by 'in a certain range' as this could mean different things, e.g. In a particular zone on the screen or within a certain distance or radius of an actor.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

Jedinator

  • Posts: 20
Thanks for the reply! I only want the player to be able to press the control when in certain distance of an actor.

« Last Edit: May 22, 2012, 05:13:27 pm by Jedinator »

Innes

  • *
  • Posts: 1960
In which case, using 'regions' is probably the easiest way... Create a circular region which follows the actor and when the player enters that region, set a flag (e.g. Boolean). When the player presses the control, check if the flag is on and, if it is, allow the control to work. You will also need to reset the flag when the actor exits the region.

Regions are well explained in Stencylpedia.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

Jedinator

  • Posts: 20
Great! Thanks. I haven't gotten that far in Stenclypedia, but I'll look it up. Thanks!

Innes

  • *
  • Posts: 1960
Which part of the planet are you on? I'm in Western Australia (it's morning here right now, and I'm working today, so I'm 'signing off' now!
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

Jedinator

  • Posts: 20
Colorado USA. about 630 pm right now :) What do you mean "reset the flag when exiting the region?"

Ryusui

  • Posts: 827
That is, set the boolean to false (or true, or whichever keeps the player from using the control) after he exits the region. It won't automatically flip back when he's out of range; you have to do it manually like this.
In the event of a firestorm, the salad bar will remain open.

Jedinator

  • Posts: 20
Thanks. So far, I have the following code, but I am having trouble with the rest of it. 

Basically, I am creating a game where the player has to create "ACTORS" by pressing a button. For example, to get over a pit, he/she would press "Z" and a "RAMP actor" would be created, wherein the main character launches off the ramp via a customized Jump behavior.  However, I don't want him/her to create multiple actors, or create them too early.  Take a look below and please advise. Thanks.

The first and second screenshots are attached to the Ramp Actor.  The third screenshot is attached to the Player, who is currently Mambo, but he is just placeholder art for the time being. Thank you.