Why do guys withdraw after got my attention?

This guy from work... I didn’t even care about him, until he started flirting me and making sexually and romantically jokes (which was fun and not weird or creepy at all) just being goofy around me. Then today he has been totally withdrawed, barely looked at me, and didn’t even say hi or else, no jokes, no flirt, nothing. So why does he got so unfriendly after he got my attention?