Why does my coworker ignore me?

My coworker ignores me from time to time, especially around other colleagues/friends, like responding with one word answers in a very unenthusiastic/passive aggressive tone, which he doesn’t do with anyone else. However, at other times during the day/next day he is very attentive to me, and we joke around together. Basically he plays hot and cold. Why does he do this?

Now I am ignoring him because I feel hurt and I don’t want to talk to someone who doesn’t seem to respect me as a friend…and he tries to talk to me/says hi to me still occasionally, despite me very obviously giving him the cold shoulder. What does this mean, why does he do this?

Why does my coworker ignore me?
Post Opinion