[Solved] How can I detect collisions when using Set X/Y?

Mad Bomber

  • Posts: 5
I'm trying to make a menu using an arrow-controlled cursor. My intent is for it to jump a standard distance when a key is pressed, check to see if it's touching an actor of the "Buttons" group, and if not, immediately return to its previous position.

From searching the forums and elsewhere, I'm gathering that collisions intentionally don't work when using the Set X/Y block, which explains all the trouble I'm having.

I've been trying to work up some kludges to get around this, but I feel like there's gotta be some elegant solution to create such a simple effect. How should I be approaching this?

« Last Edit: August 24, 2018, 03:24:28 pm by Mad Bomber »

merrak

  • *
  • Posts: 2738
Use the arrow keys to change the state of each button from "active" to "inactive". That's how the arrow control keys work in my game. Each button is assigned an index from 0  to N-1 (N = number of buttons). Pressing an arrow key activates the next button in the list.

To get the cursor affect, when a button is activated move the cursor to that position.

I remember posting a behavior that did this to the forum... or at least an earlier version of the code I described. I don't remember where it is, though. It isn't it's own thread.

Edit. Here it is. http://community.stencyl.com/index.php/index.php?topic=41034.msg292144#msg292144

Mad Bomber

  • Posts: 5
Thanks very much for your help! This makes much more sense than what I was trying to do.