There was an example of this, somewhere I dont remember. It was about grid movment and will stop the player from walking over the rocks. Did you try something like:
Keyboard---Right arrow down & player --- (invert)is overlapping "Wall" at offset(0,-gridsize) ----- then move
It a little hard to understand it that way. I will try to find the tutorial.
Edit: here is it, maybe I will help you. Note, fix the url because I cant post them.
http s:// w ww.scirra.com/tutorials/1094/grid-based-movement