Search code examples
buttoncocos2d-xrounded-corners

Rounded buttons in cocos2d-x


With the normal Button class in cocos2d-x, we can create round buttons by using images having the edges rounded off. However the hit testing still "works" on the invisible edges because there is likely just no such feature to ignore the touches that occur on the invisible parts and/or the edges. Does anyone know a fix/workaround for this?

The purpose is to not have the button be tapped if the tap is on an area within the rectangle and on a 0 opacity point.


Solution

  • You should definitely check this IrregularButton class made by Shuai Yuan.