Hello friend.
I think you should use arrays for this. Maybe you can use the official tilemap as well.
The idea is that you will have an array, and for each tile on your layout, the corresponding array adress (i.e. x=5 y=10) will hold a value indicating the state of the sprite at that adress.
Imagine your level as a chessboard. Each square is represented on the array. If there is a piece on any adress, the value in the array will be 1. If empty, it will be 0.
Then your array will look like this:
0,0,0,0,0,0,0,0
0,0,0,1,0,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
You will then have an event mechanism that for each adress on the array, checks the neighbouring adresses, and if they also have a sprite in that direction, sprite frames will be updated accordingly. With the above example, since there is only one object on your level, nothing will happen. But if:
0,0,0,0,0,0,0,0
0,0,0,1,1,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
When the event detects the tile in (3,1) has an object (remember, arrays are 0-based in c2, meaning first line or row starts to count with 0, not 1), it will change it's sprite frame. To which frame it will change you will decide with which direction it has a neigbouring piece. Since in this case it will have a piece on right, (and the piece in(4,1) has a piece on left) it will change accordingly. I hope I could explain myself.
This is the hard-ish way of doing this, but if you succeed, not only you will have delved deeper into development, you will also have a scalable basis for many other games you could build in the future.
It may be possible with easier, on-the fly ways but I think this is the best aproach.