Hi. I have 3 troll sprite instances, on a horizontal platform.
This is The CAPX
When ctrl is held and an arrow key is pressed, I cycle between them by adding +1 to the instance number or subtracting 1 from the instance number
The problem is, if the trolls move from their original positions, they are not in the correct order any more. So by pressing ctrl+arrow, you don't necessarily select an adjacent troll any more :(
So I found a way to dynamically assign an Xindex number to each instance, by using a loop and comparing the X position to a minimum and maximum X.
So then, every time I press ctrl, the troll instances get numbered 0, 1, 2 (leftmost, middle, and rightmost troll respectively).
What do I do with the horizontal index though? How can I use it to always select the sprite to the right, when pressing ctrl+right, or the sprite to the left, when pressing ctrl+left ?
I may be overthinking it, so I'm stuck.
If anyone has any idea, I'd be grateful