Hello world!

April 14th, 2010

Welcome to Leetr.com Blogs. This is your first post. Edit or delete it, then start blogging!

iPhone: Launching iTunes links from UIWebView

December 21st, 2009

Add the following code to your UIWebViewDelegate:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        [[UIApplication sharedApplication] openURL:request.URL];
        return false;
    }
    return true;
}

iPhone: How to make iPhone vibrate

December 11th, 2009

Add ‘AudioToolBox’ framework

//import the necessary files
#import 

// Vibrates the phone
- (void)vibratePhone {
  AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
}

iPhone: Change the app name under icon.

December 1st, 2009

This one is easy to. Change the ‘Bundle display name’ value in the Info.plist file.

iPhone: Custom Fonts Using Zynga's FontLabel Class

November 30th, 2009

Using custom fonts is not the most straight forward thing on the iPhone. Luckily good people at Zynga developed an easy to use FontLabel class. Download it here. Add the files to your project.

Step 1. Import the FontLabel header:

#import "FontLabel.h"

Step 2. Create a label.

//note the name of my font file is 'Rage italic.tty'
FontLabel *label = [[FontLabel alloc] initWithFrame:CGRectMake(10, 10, 210, 110) fontName:@"Rage Italic" pointSize:30.0f];

//set the color
label.textColor = [UIColor colorWithRed:0.254 green:0.216 blue:0.078 alpha:1];

//set the text
label.text = @"Denis you're a handsome man!";

//skip the background. make it transparent
label.backgroundColor = nil;
label.opaque = NO;

label.lineBreakMode = UILineBreakModeTailTruncation;

//dynamic number of lines
label.numberOfLines = 0;

//text alignment
label.textAlignment = UITextAlignmentCenter;

//add to where you need it
[myView addSubview: label];

//and release it
[label release];

iPhone: Rotate an UIImageView

November 30th, 2009

Couldn’t be easier. Just make sure that degrees are in radians.

imgView.transform = CGAffineTransformMakeRotation (degrees);

You can spice it up with animation:

[UIView beginAnimations:@"rotateAni" context:nil];
//set the duration to 5 seconds
[UIView setAnimationDuration:5.0];
imgView.transform = CGAffineTransformMakeRotation (degrees);
[UIView commitAnimations];

iPhone: Launching iTunes from Apps

October 28th, 2009
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://phobos.apple.com/WebObjects/your_app_link_here"]];

iPhone: cocos2d: Fix flicker at start up

September 15th, 2009

Put this code right before you run you first scene ( Assuming that you have “Default.png” file ):

// prevent flicker
Sprite *sprite = [[Sprite spriteWithFile:@"Default.png"] retain];
sprite.anchorPoint = CGPointZero;
[sprite draw];
[[[Director sharedDirector] openGLView] swapBuffers];
[sprite release];

// Run the intro Scene
[[Director sharedDirector] runWithScene: introScene];

iPhone: Current Time in Milliseconds

August 27th, 2009

This is how to get Unix time

[[NSDate date] timeIntervalSince1970];

Game Sneak Peak

August 16th, 2009

game_peaking

That all for now, stay tuned for more.