A cue is like a signal. In a play in the theatre your cue is the line or moment in the play when you have to walk on stage or do something. "On cue" is something happening when it is planned to happen. The train was due at 3.34 and it turned up right on cue (meaning, right at the planned time.) "As if on cue" means something happening that appears to be planned but is just a coincidence. In Anthony's example you are talking about someone and suddenly that person appears, like they got a signal to come. It is a coincidence but it seems like ("as if") it was planned. Hope that helps.