Why did he slap my butt?

I was standing talking with my friends, and he came by and slapped my butt. I have no idea why because we are just friends. He knows I like him and stuff but still. I can't figure out why!? Please help? After he did it he just walked away and yes it was on purpose because it was hard! He has also been a lot nice to me lately.
Why did he slap my butt?
Post Opinion