You could use a Tilemap for this:
For example:
Set the Empty tiles to (Tile = 0)
Set the obstacles to (Tile = 1)
-On Tile Clicked extract the X&Y into a Local variable
-Loop in the 4 directions by using the System "For" loop:
> Dir Right ---> For "X" From (TileX +1) To ((Tilemap.Width/TileSize) -1)
---------> Tile at(LoopIndex("X"), Y) is not equal 1 ------> Set tile to your desire frame
---------> Else: Stop the loop
Dir Left ---> For "X" From (TileX -1) To (0)
---------> Tile at(LoopIndex("X"), Y) is not equal 1 ------> Set tile to your desire frame
---------> Else: Stop the loop
Dir Up---> For "Y" From (TileY -1) To (0)
---------> Tile at(X, LoopIndex("Y")) is not equal 1 ------> Set tile to your desire frame
---------> Else: Stop the loop
Dir Down---> For "Y" From (TileY +1) To ((Tilemap.Height/TileSize) -1)
---------> Tile at(X, LoopIndex("Y")) is not equal 1 ------> Set tile to your desire frame
---------> Else: Stop the loop
Probably a second condition is needed there to make you stop at the edges so you dont check outside the tilemap.
Tile is not equal to -1
Tile is not equal to 1
If you really need to use sprites then you can still do all the tile checks in the tile map as I showed above and then when you need to change the frames just pick the Sprite tile that is located on that Tile by using Pick by overlapping Point XY
or
alternative you can do the same job by using just sprites alone if you add two variables to the sprites:
Tx
Ty
At the start of the layout do a loop to set all the (Tx & Ty) variables and use the same system as the tilemaps. But this time pick tiles by comparations:
> Tile.Tx = X
Tile.Ty = Y
Thanks for the reply, I will try to do so.