Cocos2dUtilities
Utilities developed by HurleyProg for use with Cocos2d
 All Classes Functions Variables Properties Pages
Instance Methods | Class Methods | Protected Attributes | Properties | List of all members
CCButton Class Reference

#import <CCButton.h>

Inheritance diagram for CCButton:

Instance Methods

(void) - disable
 
(void) - enable
 

Class Methods

(id) + spriteWithFile:withPressedFile:target:function:
 
(id) + spriteWithFile:withPressedFile:touchAreaScale:target:function:
 
(id) + spriteWithFile:withPressedFile:touchAreaScale:priority:target:function:
 

Protected Attributes

SEL _selector
 
id< NSObject > _target
 

Properties

id< NSObject > target
 
SEL selector
 

Detailed Description

A subclass of CCSprite which adds itself to the touch dispatcher. When touched it will call specified selector on the supplied target. Can also increase/decrease the touchable area which is helpful when making small images into buttons. This class has only been tested in landscape mode.

Method Documentation

- (void) disable

Disables the button. Makes the button darker to look disabled

- (void) enable

Enables the button. Removes the disabled look

+ (id) spriteWithFile: (NSString *)  filename
withPressedFile: (NSString*)  pressedFilename
target: (id)  object
function: (SEL)  callback 

Initialzes the sprite and sets the sprite's touch area equal to the bounding box

Parameters
filename- The file to use as the non-pressed image.
pressedFilename- The file to be used as the button's pressed image
object- The object that the selector will be called on
callback- The selector to be called on the target
Returns
returns an autoreleased object for use with cocos2d objects
+ (id) spriteWithFile: (NSString *)  filename
withPressedFile: (NSString*)  pressedFilename
touchAreaScale: (float)  scale
priority: (int)  priority
target: (id)  object
function: (SEL)  callback 

Initialzes the sprite but allows the user to scale the touch area based on the bounding box of the button.

Parameters
filename- The file to use as the non-pressed image.
pressedFilename- The file to be used as the button's pressed image
scale- Scales the touch area by the amount specified. A value of '1.0' makes the touch area the same size as the button bounding box.
priority- Sets the priority for the touch dispatcher otherwise defaults to 0
object- The object that the selector will be called on
callback- The selector to be called on the target
Returns
returns an autoreleased object for use with cocos2d objects
+ (id) spriteWithFile: (NSString *)  filename
withPressedFile: (NSString*)  pressedFilename
touchAreaScale: (float)  scale
target: (id)  object
function: (SEL)  callback 

Initialzes the sprite but allows the user to scale the touch area based on the bounding box of the button.

Parameters
filename- The file to use as the non-pressed image.
pressedFilename- The file to be used as the button's pressed image
scale- Scales the touch area by the amount specified. A value of '1.0' makes the touch area the same size as the button bounding box.
object- The object that the selector will be called on
callback- The selector to be called on the target
Returns
returns an autoreleased object for use with cocos2d objects

Member Data Documentation

- (SEL) _selector
protected

The selector to call when the button is pressed

- (id<NSObject>) _target
protected

The object which the selector will be called on

Property Documentation

- (SEL) selector
readwritenonatomicassign

The property for the selector variable

- (id<NSObject>) target
readwritenonatomicassign

The property for the target variable


The documentation for this class was generated from the following files: