Sense Actor Type/Orientation On Screeen

Hi all! I'm fairly new to Stencyl and I'm trying to make this feature work in a simple game I'm making. What I'm trying to do is make it so that when two squares are aligned in my game they trigger an event (I.E. winning the level). So far, I've just been able to do this in the actual scene and not in any advanced code. It would help to have this code line somehow in an actor or scene beahvior so that I wouldn't have to implement the code for every level over and over.

As you can see, I'm trying to make it so that if the spaces in each square line up, an event triggers. It should only trigger if 1. the squares are right beside each other (in the 32x32grid) and 2. if they are each in the correct animation (with the spaces aligning).

Thanks for any and all help!!!


Chum

  • Posts: 3
I think there is no other way than doing this in scene events:
When updating
      if box 1 animation = [e.x. down] and box 2 animation = [e.x. up]
{and then showing the victory screen}
I hope it helps

RosalinaGalaxer

  • Posts: 157
You could potentially do it with collision boxes: make a new collision box on one side of the actor (the side the space is on) in  a special collision group that collides as a sensor. It should only collide with others of the same collision group. Then, check if two of the same group are colliding, (use the Group-Group event in the collisions section) and set them to "Locked In".

Hope that helps. I could try to give a visual example if you need it.
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̯͍̓̇̾̎Ť̵̳̻̙̦̈́̅̓͆̚h̴̗̩̫͖̍͑̋̋͗͜͜e̴̻̰̔̂ ̷̢͈̖̏́b̸̘̻͖̣̙̍͒̆́a̶̺̗̟̿͒n̵̡̼̘̺̚ḙ̸̗̹̥̜͐͘͝ ̸̨̮̭̳̓͜ō̸̧͙̜̮̌͑f̴̜̒̔̆͊ ̵̪̹̱̪̌͘͝Y̸͔̪̽͠u̷̱̳̟͒̂̊͒̕͜ḿ̸̡̤͚̬̪ë̵̪͍̹͝k̶̝̣̗̞̹̖̅̊̅y̶̧̞̟̤͚̋̀̔o̴̯̾'̷̠̐̋͂̇̿̕s̴̡̬̲̠̰̦͗͂ ̴̢̘̤̝͆̀͘b̸̛͖̲͒̅̊̏͝o̶̘̮͊͐͗̇͠͝r̷̰͓͍̣̀̄d̷̢̞̂̚e̶͖̲̯̰̫̅̈͗r̸̢̒̊͜ͅ

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

JeffreyDriver

  • Posts: 1860
Instead of having different animations, you could just change the direction of the actors by pointing them in certain directions. It might make it easier to manage.

As for checking the position, you can just simply check the X and Y values on one actor in relation to the other.
Current Projects:
Retro Redux Compilation (NEW).
Retro Redux (untitled) (NEW).
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

Instead of having different animations, you could just change the direction of the actors by pointing them in certain directions. It might make it easier to manage.

As for checking the position, you can just simply check the X and Y values on one actor in relation to the other.

As for checking the x/y axis, what blocks can be used to to do this?

You could potentially do it with collision boxes: make a new collision box on one side of the actor (the side the space is on) in  a special collision group that collides as a sensor. It should only collide with others of the same collision group. Then, check if two of the same group are colliding, (use the Group-Group event in the collisions section) and set them to "Locked In".

Hope that helps. I could try to give a visual example if you need it.

A visual help would hope a lot, as I've never really worked with collision groups that much before.

JeffreyDriver

  • Posts: 1860
Instead of having different animations, you could just change the direction of the actors by pointing them in certain directions. It might make it easier to manage.

As for checking the position, you can just simply check the X and Y values on one actor in relation to the other.

As for checking the x/y axis, what blocks can be used to to do this?

See attached image. Note this is for just two actors, and as you add more, your code is going to get more complex.
Current Projects:
Retro Redux Compilation (NEW).
Retro Redux (untitled) (NEW).
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

RosalinaGalaxer

  • Posts: 157
Here we go. This post is abnormally long, mostly due to screenshots.

In the actor, navigate to the "Properties" tab. Click the last option: "Edit Groups..."



In there, you'll want to click "Create New" and make a new group. Make sure it can only collide with itself:



Now, navigate to the "Collisions" tab. There, click "Add Box". You can make any size you want, but I just made it five across and thirty-eight in height, for demonstration purposes. Ideally, I should have made it so that it is only touching one side of the box: don't make it the same height or width as the actor, or it could trigger when it's not in the right position. Make sure to position the box on the side that the space is on in the animation. If you go with JeffreyDriver's rotation suggestion, then you only need to make one box; animation switching is unnecessary.



And finally, the code that makes it work. You're going to need to make a boolean attribute(call it anything you want, just make sure you type it's name where I've typed Lock In). Then, it's pretty straightforward:



You can find those blocks at the bottom of the "Properties" tab in the "Actors" section (on the Block Palette, not the tabs up above).

Hope that helps! Good luck!
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̯͍̓̇̾̎Ť̵̳̻̙̦̈́̅̓͆̚h̴̗̩̫͖̍͑̋̋͗͜͜e̴̻̰̔̂ ̷̢͈̖̏́b̸̘̻͖̣̙̍͒̆́a̶̺̗̟̿͒n̵̡̼̘̺̚ḙ̸̗̹̥̜͐͘͝ ̸̨̮̭̳̓͜ō̸̧͙̜̮̌͑f̴̜̒̔̆͊ ̵̪̹̱̪̌͘͝Y̸͔̪̽͠u̷̱̳̟͒̂̊͒̕͜ḿ̸̡̤͚̬̪ë̵̪͍̹͝k̶̝̣̗̞̹̖̅̊̅y̶̧̞̟̤͚̋̀̔o̴̯̾'̷̠̐̋͂̇̿̕s̴̡̬̲̠̰̦͗͂ ̴̢̘̤̝͆̀͘b̸̛͖̲͒̅̊̏͝o̶̘̮͊͐͗̇͠͝r̷̰͓͍̣̀̄d̷̢̞̂̚e̶͖̲̯̰̫̅̈͗r̸̢̒̊͜ͅ

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

Thank you all! sorry for the long respond but finally implemented a mix of all these answers and it worked! thanks to the wonderful help here my game will live on! Thanks all!

RosalinaGalaxer

  • Posts: 157
No problem! This game looks like it has some potential, and it would be great to see it show up on Armor Games or Steam or something of the like.
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̯͍̓̇̾̎Ť̵̳̻̙̦̈́̅̓͆̚h̴̗̩̫͖̍͑̋̋͗͜͜e̴̻̰̔̂ ̷̢͈̖̏́b̸̘̻͖̣̙̍͒̆́a̶̺̗̟̿͒n̵̡̼̘̺̚ḙ̸̗̹̥̜͐͘͝ ̸̨̮̭̳̓͜ō̸̧͙̜̮̌͑f̴̜̒̔̆͊ ̵̪̹̱̪̌͘͝Y̸͔̪̽͠u̷̱̳̟͒̂̊͒̕͜ḿ̸̡̤͚̬̪ë̵̪͍̹͝k̶̝̣̗̞̹̖̅̊̅y̶̧̞̟̤͚̋̀̔o̴̯̾'̷̠̐̋͂̇̿̕s̴̡̬̲̠̰̦͗͂ ̴̢̘̤̝͆̀͘b̸̛͖̲͒̅̊̏͝o̶̘̮͊͐͗̇͠͝r̷̰͓͍̣̀̄d̷̢̞̂̚e̶͖̲̯̰̫̅̈͗r̸̢̒̊͜ͅ

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz