Tag Archive for ‘Quick Code’

Quick Code: URL Encoding – mailto example

Ever notice that when you go to a website there are some strange percent sign things going on up in the address bar? Well that’s URL encoding. You are probably most familiar with %20. That’s a space. When typing out Objective-C code, if you need a URL encoded string (maybe for a GET request), there

Continue reading »

Quick Code: CCNode setPosition: #macro (You will love this!)

For those that love cocos2d as much as I do, you know that basically everything is a subclass of CCNode.  Position is a the location in points (not pixels) of a CCNode where (0,0) is the bottom left corner of the parent object. Once you get into writing cocos2d apps, you will find that you

Continue reading »

Quick Code: Starting and Stopping SpaceManager

I plan on doing a longer tutorial on SpaceManager a little bit later but for right now I wanted to post a quick bit of code that should seem rather obvious, but took me a while to figure out. Straight from the SpaceManager website: SpaceManager was designed specifically to target chipmunk for use on the

Continue reading »

Quick Code: Link to Ratings in App Store

What’s the best way to get people that have played your app to rate your app?  Put a link to your ratings page in your app of course! One method of putting a link to your ratings page in your app is to just plop it down and tell people to click it. A different

Continue reading »

Quick Code: CCLabelTTF color

Tired of the same old white labels with CCLabelTTF in cocos2d? Changing the color is super simple! CCLabelTTF *label = [CCLabelTTF labelWithString:@"I love Paw Apps!" fontName:@"Marker Felt" fontSize:36.0f]; [label setPosition:ccp(200,200)];   // Notice the following three ways all do the same thing. // The color is set to Blue, Red, and then Green. // Of

Continue reading »

Quick Code: CCLayerColor and CCLayerGradient

Today’s quick code is about using CCLayerColor and CCLayerGradient.  These two objects are very useful for one, because of their simplicity, and for two, they keep you from making new sprite objects. Before I knew these objects existed, I would create a solid color 480×360 and 960×720 solid color image to use as a background

Continue reading »

Quick Code: performSelector:withObject:afterDelay:

Awesome little bit of code here.  Any time you want a bit of code to run in the future, you can schedule it to run after a number of seconds delay.  For this you use performSelector:withObject:afterDelay:. It really works just as simple as it looks. Here’s a quick example: [mySprite performSelector:@selector(setVisible:) withObject:[NSNumber numberWithBool:YES] afterDelay:2.0f]; This

Continue reading »