/cocos2d-ext

Some usefull classes, categories I've developed to simplify everyday tasks of game development with cocos2d

Primary LanguageObjective-C

Some classes/categories included in this project:

+ CCNode+Ext
    This category defines the "collidable" rectangle of a node, @selector(rect), which has the default 
    returned value is a rectangle has origin at (0,0) and the size is equal to the node's contentSize. 
    You can check if two nodes are overlapped with @selector(isCollideWithNode:). This method uses 
    Separating Axis Theorem to determine the intersection beteween the nodes' rects. This method is very
    useful for simple collision detection.
    This category also contains methods to convert a point from another node's coordinate to the 
    caller node's coordinate, and to check if a node contains a point in world coordinate... 


+ Utils
	Contains some utility functions

+ Config
	Util class to deal with plist. Providing simple way to read/write plist by path (ie. "user/info/name").
	This class is very useful to store your game configuration (that why it is named "Config"), 
	level data and other information that is not too large.
	It also support encryption (AES256), so you are no longer worry about users hacking into your
	data.
    You can use Config as singleton:
    //Return the shared Config instance of file "config.plist" in Document directory
    Config *config = [Config instanceForFile:[Utils pathForFileInDocument:@"config.plist"]];
    //When you're no longer need it 
    [Config removeInstance:config]; 
    //Or [Config removeInstanceForFile:[Utils pathForFileInDocument:@"config.plist"]];

    You can also create non-singleton instance with 
    [[Config alloc] initWithFile:[Utils pathForFileInDocument:@"config.plist"]];

+ ScoreManager
	If you want to save hight scores for your game, this class is a good choice. You can have many score 
    categries (ie. one categry for Touch Mode and one categry for Tilting Mode). Scores can be sorted ACS
	or DESC. ScoreManager uses Config to store your scores.  
    
    To create a ScoreManager:
    ScoreManager *manager = [[ScoreManager alloc] initWithFile:[Utils pathForFileInDocument:@"score.plist"]];
    score.plist may contains the scores limit (__SCORES_LIMIT__ key) and scores sorting (__SCORES_SORTED__ key).
    If the values of these keys are not set, 50 is used for scores limit, and 1 (DESC) is used
    for scores sorting. You can change these values any time with the manager's properties. 
    
    To insert a new score:
    [manager insertScore:1024 name:@"pete" category:@"basic"];
    [manager save];    

    To retrieve all sorted scores:
    NSArray *scores = [manager scoresInCategory:@"basic"];
    This methods returns an array of Score objects. A Score object has name, score, rank, date, category
    and an extra field.
    

+ CCSlider
	I write this class to achieve a game music volume control. 
	
+ GameSound
	A wrapper of SimpleAudioEngine. The idea is to do everything related to music & sound in this
	class. GameSound automatically store the last configuration you made to it in NSUserDefaults
	(ie. music volume, sound effect volume) and when the GameSound is initialized, the last 
	configuration is restored.
	
+ CCBlade 
	Similar to the knife blade effect you see in famous Fruit Ninja	
	
+ Ragdoll
	Ragdoll implementation with Box2D
	
+ CCComponent (subclass of CCSprite)
	I write this class with the idea to encapsulate everything regarding to a game actor. Don't 
	confuse the word "component" in CCComponent with Component Based architecture. This class has
	nothing to do with Component Based architecture. Long story short, one of the most benifit of 
	CCComponent that I've used in many projects is to simplify the manipulation of actore's "states".
	A "state" is an action that an actor can do. CCCompnent supports some kinds of states (rotate, 
	scale and animating frames). For example, if you need to animate a Lion to simulate a "Run" action,
	you need a couple lines of code (actually I don't remember how to do this). With CCComponent, you just need 
	to define this action as a state, name "Run", in a plist (with predefined keys), CCComponent reads this plist,
	parse it and do every heavy things behind the scene, and all you need to do is an assigment:
		lion.state = @"Run"
	This save a lot of my time :).
	It also have many other features. I will update this README soon.