Quantcast
Channel: Soft Werewolf » ios
Viewing all articles
Browse latest Browse all 8

My SimpleButton Cocos2D class

$
0
0

Cocos2D for iPhone sadly does not have a class for a button that lets you customize it with different text, text color, and background color. After some research, I decided the easiest way to do this on my own would be to create a button from a blank sprite, set a color for that sprite, and attach the text to that sprite. So I created a class that did just that. This weekend, I upgraded the class a bit to support a border and simple drop-shadow (really just a slightly displaced block of color). It’s still acting a little weird, but I put some hours into it, so I’ll post the code here for those who may want to see what I did.

SimpleButton.h, SimpleButton.m

I use the class by creating the button and then messing with the padding, borderWidth, and shadowOffset properties. Here’s a screenshot of the current Dungeonism zone menu, which uses the class:

Dungeonism Menu


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images