Wednesday, July 4, 2012

Lessons/Stanford: Programming Leassons

Hi!

Here's a quick tip for everyone who wants to learn more and didn't go to college or wants or simply enjoys to get as much information possible:


Enjoy!

PS. I mustn't forget to thank Caue for the hint, I already had atended to the iOS classes but didn't know about the others, so, "Thank you, Cauê (L)"

Monday, May 14, 2012

Cocos2d/Gamecenter: How to implement correctly GameCenter into Cocos2d

Hi,

How's it going there?
Here's a tutorial that i saw loads of people having the same problem and after some research  I figured it out.

I don't know if it's the ideal way, but as it worked I can suit you.

Cocos2D: 1.0.1

What was the problem that it wouldn't work?
R: For some reason the RootViewController wasn't referenced and so it gave me a 12h delay on the project.

Step 1:

Go to you AppDelegate.h


#import <UIKit/UIKit.h>

@class RootViewController;

@interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
RootViewController *viewController;
}

@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) RootViewController *viewController;

@end



Step 2:

Go to your AppDelegate.m


#import "cocos2d.h"



#import "AppDelegate.h"

#import "RootViewController.h"

@implementation AppDelegate

@synthesize window;
@synthesize viewController;

- (void) applicationDidFinishLaunching:(UIApplication*)application
{
// Init the window
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    window.rootViewController = viewController;
//blablablá
// Init the View Controller
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
}

Step 3:

Import GameKit.framework

Step 4:

Implement some code.
I'm going to put only some basic stuff and of course the most important the leaderboard.



-(void)localUserAuthentication{

    

    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    [localPlayer authenticateWithCompletionHandler:^(NSError *error) {
        if (!error){
            isLocalUserAuthenticated = YES;
            //NSLog(@"AUTHETICATION SUCCEDED");
        } else {
            isLocalUserAuthenticated = NO;
            //NSLog(@"AUTHETICATION FAILED");
        }
    }];
}





-(void)showLeaderboard{
    
    
    GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
    if (leaderboardController != NULL) {
        leaderboardController.category = @"com.yourcompany.gamename.leaderboard.whatleaderboard"; 
        leaderboardController.timeScope =GKLeaderboardTimeScopeAllTime;
        leaderboardController.leaderboardDelegate = self; 
        AppDelegate *delegate = [UIApplication sharedApplication].delegate; 
        [delegate.viewController presentModalViewController:leaderboardController animated:YES];
    }
    
    leaderboardController.toolbar.autoresizesSubviews = YES;
    leaderboardController.view.bounds = CGRectMake(0, 0, 480, 320);
    leaderboardController.view.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));
}



-(void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController{
    CCMenu* gamemenu = (CCMenu*)[self getChildByTag:kGameMenu];
    gamemenu.isTouchEnabled = YES;
    [self show];
    
    AppDelegate *delegate = [UIApplication sharedApplication].delegate; 
    [delegate.viewController dismissModalViewControllerAnimated:YES];
}



Well, so that's that.
If you guys need any help, just get in contact.
Hasta luego.

Thursday, January 26, 2012

XCode/Archiving: Uploading Archive Problem

How's going, everybody?


Well, here's a quick tip on what can help you when you get the dreadful error while you're uploading your archive to the store:




'iPhone/iPod Touch: application executable is missing a required architecture. At least one of the following architecture(s) must be present'



This is a error that really sucks because, dudes! The last thing after 120 hours working on your code is an error for uploading the thing. But here is what you do:




1)Select your project "stuff" up there;
2)Select the "PROJECT" option;
3)Go to "Architectures";
4)Press on top of the up-and-down arrow;
5)Inserting the "armv6" thing:
    5.1) Delete any option that you have there:
        5.1.1)Select the option;
        5.1.2)Press the "-";
    5.2) Press the "+";
    5.3) Insert the "armv6";
    5.4) Probably you'll need to press some type of confirmation.




That's it.
Cheers.

Friday, January 20, 2012

Cocos2D/Orientation: How to get the orientation you want.


Yo, dudes,

How's it going? Kind of shitty, hun? No Megaupload, no FBI, no WhiteHouse.
What else to do? Well, here goes a fast topic for orientation issues.
Know when you have that real cool game that you're using Cocos2D but want to use Portrait Orientation?
Just do This:


1) Go to "RootViewController.m";
2) Find this piece of code:



#elif GAME_AUTOROTATION == kGameAutorotationUIViewController
//
// EAGLView will be rotated by the UIViewController
//
// Sample: Autorotate only in landscpe mode
//
// return YES for the supported orientations
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );

3)Change the "UIInterfaceOrientationIsLandscape" to "UIInterfaceOrientationIsPortrait", or any other that you would like. (Just try not using "PortraitUpSideDown" if would be kind of awkward.

Now your code should be something like this:

#elif GAME_AUTOROTATION == kGameAutorotationUIViewController
//
// EAGLView will be rotated by the UIViewController
//
// Sample: Autorotate only in landscpe mode
//
// return YES for the supported orientations
return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );


Any problems, get in contact.
Cheers.

Friday, December 2, 2011

XCode/Objective-C: Xcode 4.2 and MainWindow.xib

Bros,


After a long search on the Oracle (Google) I found it.
The on thing that really pissed me on XCode 4.2 (AKA last version), what that "View Based Application" does not exist anymore and i was like "WTFH am I going to do now?!".


So today, i found the solution!


Who found it out?


                       Joroen Trappers - click here and do directly to his solution/post


From whom did i get the first post?


                      Chris's Laboratory - click and go the post




If you guys need anything, just get in contact.
Live long and prosper, peace.

Thursday, December 1, 2011

Beyond/Nerdiosity: Rap battles

Dudes!


Here are two videos that you'll crack you head of, so just have fun.
Aqui vai dois videos para você se divertir.




Einstein X Stephen Hawking




Vader X Hitler



Friday, November 25, 2011

Objective-C/Cocoa: Star Rating Class

Hi breathers,


How's it all going?
It's been a time since i posted, so here's some nice stuff.


Know all those games that rate you after the match(e.g. Angry Birds) with the star system-thing, so i made on very simple so you just need to copy and paste on your project.


Download: StarRate Class (WARNING: Very Huge Dowload - 3K)


Probably you'll would like to add other sizes of banners, so just feel free to use the class as you want.


Oh, yeah! One last thing. I know this is a stupid comment, but remember you're not going to use it directly on the  "-(void)viewDidLoad". Normally you'll use it when the match is ended and on the "level" boxes to display the last rate the player had on that match/level.


After you import the code to your project you have to do this:



#import <UIKit/UIKit.h>

#import "StarRate.h"



@interface StarTestViewController : UIViewController{
    StarRate *_stars;
}

@end


#import "StarTestViewController.h"





@implementation StarTestViewController


-(void)createStars{
    _stars = [[StarRate alloc]init];

    //THIS setBackgroundColor YOU CAN ADD TO THE CLASS I UPLOADED FOR YOU
    //ON THE -(void)startUp METHOD
    [_stars setBackgroundColor:[UIColor clearColor]];
    [_stars setupInterfaceTheWayIWantWithType:STARBANNER_250X50 andRate:2];
    [_stars setCenter:CGPointMake(160, 240)];
    [self.view addSubview:_stars];
}


-(void)viewDidLoad{
    [self createStars];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [super viewDidLoad];
}

(...)


@end






As you can see, i didn't use InterfaceBuilder, i'm kind of on strike with him, so fell free to use InterfaceBuilder if you want, you just need to remember how to inherit a normal UIView to StareRate.

If you need help, just go to the Contact Section and let me know.
Live long and prosper.


Tweet