Yeah, button press visuals are great! Cocos2d is nice enough to provide a darkening of the button when we touch it, but let's add a bit more animation to our buttons to give them more of that "clicked" feeling.
If we just wanted an individual button to have a specific effect, we would modify just that single button in the place where it exists. However, we want the same button effect across all buttons in our game, so we need to open CCButton.m
file. The easiest way to do that is to search for CCButton
in the project and click on any of the links to CCButton.m
.
Here, you're going to add two functions near the top of the file: scaleButtonUp
and scaleButtonDown
. Both of them run actions on the button, and these actions give it a bouncy press effect found in many games: