Using noise making devices such as horns from a bike or boat. Giving the cat a puff of air in the face from a can of compressed air. Hitting slapping, or scruffing a playfully aggressive cat is not acceptable. This approach seldom corrects the problem and can have some nasty results. Your cat may become more aggressive, afraid of you, or both.
Punishment alone is never an effective treatment.
Resolving play-motivated aggression problems must include encouraging the cat to play appropriately and may include remote punishment techniques designed to discourage the cat from showing undesirable play behaviours. It is not uncommon for cats to suddenly bite while being petted. This behaviour is not well understood, even by experienced animal behaviourists. For whatever reason, petting which the cat was previously enjoying apparently becomes unpleasant. Cats vary in how much they will tolerate being petted or held.