Try nesting your sprites in YSort. They will automatically layer them selves to foreground and background of each other by y position.