Tag Archives: cocos2d

Tilt Shift Effect in Cocos2d (v2.0+)


The < - image(click to see larger view) showcase my experiment with shader in Cocos2d (v2.0). A modified box blurring algorithm was used in the fragment shader and this is only applied to sprites (each individual building is a separate sprite) that are above or below the two hardcoded threshold (y-position). The blurring algorithm was modified in such a way that the amount of blur applied to the sprite is dependent on how far above or below either y thresholds the sprite is. Continue reading Tilt Shift Effect in Cocos2d (v2.0+)

Objective-C Singleton Class

Using this SynthsizeSingleton.h to create a singleton class in obj-c.

Include the .h into project.


into the ClassName.h.

And add


into ClassName.m.

That…should be about it. Unless i missed some stuff out…. will look over…

oh You can then call the class by using

[[ClassName sharedClassName] someProperty];


Cocos2d Pop Scene With Transition

Pasting this here for my future reference. Originated from the cocos2d-iphone forum.

Add this to CCDirector.h, just after the declaration -(void)popScene (line 402):

- (void) popSceneWithTransition: (Class)c duration:(ccTime)t;

Then add this to CCDirector.m, just after the definition of -(void)popScene (line 768):

-(void) popSceneWithTransition: (Class)transitionClass duration:(ccTime)t {
    NSAssert( runningScene_ != nil, @"A running Scene is needed");
    [scenesStack_ removeLastObject];
    NSUInteger c = [scenesStack_ count];
    if( c == 0 )
        [self end]; 
        CCScene* scene = [transitionClass transitionWithDuration:t scene:[scenesStack_ objectAtIndex:c-1]];
        [scenesStack_ replaceObjectAtIndex:c-1 withObject:scene]; nextScene_ = scene; 

You can call the method like this:

[[CCDirector sharedDirector] popSceneWithTransition:[CCSlideInRTransition class] duration:0.5f];

Adwhirl and Cocos2d-iPhone

I had previously meddled with iAd implementation in a cocos2d project before, so implementing it in ROTATE (a game project in progress) was simply copy-pasta. Then an issue was discovered as I researched into mobile ad networks: iAd is not as efficient as I hoped and it is not available for apps worldwide (it is limited to some countries as of now). Since I am looking to release both DROP and ROTATE to be free and ad-supported games, I need an effective solution. Adwhirl, that’s what I came across. It mediates ad banners from different networks and put them into your app.
Continue reading Adwhirl and Cocos2d-iPhone

Game Center: Leaderboard

My project Drop, which has been in development for almost a year, is being stalled due to various reasons. Pretty much stuck on the artistic side of stuffs, but it will be completed. Meanwhile I have already began work on another game project, one thats based on a much simpler premise and I foresee a development time of no more than a month.
Continue reading Game Center: Leaderboard