Showing posts with label PROBLEMS. Show all posts
Showing posts with label PROBLEMS. Show all posts

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.

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.

Monday, August 8, 2011

Xcode: Archiving with multiple-application bundle

Good shinny morning kids,


This post is going to be fast, just to terminate the problem in submitting your app to the Store and receives that pain-in-the-neck "multiple-application bundle" error:


In my case it happened because i use cocos2d (http://www.cocos2d-iphone.org/).


ERROR:


"[YOUR-APP-NAME] does not contain a single–bundle application or contains multiple products. Please select another archive, or adjust your scheme to create a single–bundle application." 


RESOLUTION:


1st STEP: click on your project;
2nd STEP: click on build settings;
3rd STEP: select your static libraries (in my case it's cocos);
4th STEP: go to the option "Skip Install" (sorry for the wrong positioning of the arrow) and in the option of your static library put "YES" and in you project and target project confirm that it's chosen "NO";






That's a wrap, folks.


Credits to the dudes that helped me:


http://stackoverflow.com/questions/5206536/archiving-project-in-xcode-incorrectly-creates-multi-application-bundle



Saturday, August 6, 2011

Linux: Grub Loader Order & Keyboard Problem

Good afternoon, dudes,


After a long time cracking up my head with the GRUB loader order because i was having some serious problems with my keyboard in the console, i got really pissed off and was almost sending Debian by the Windows (got it?), but today i just got it right.


So i'm going to spill the milk and give a hand for these two situations:


GRUB BOOT LOADER ORDER:


    Commands you will do:
        1) ENTER AS "root": 
            1.1) su
            1.2) "enter with you password"
        2) GET IN THE GRUB DIRECTORY: cd /boot/grub
        3) FIND OUT IF YOU HAVE THE ARCHIVE: ls | grep grub
            3.1) IF (grub.cfg == EXISTS)
                         EXECUTE: vi grub.cfg
                   ELSE
                         TRY TO FIND THE RIGHT ARCHIVE TO EDIT
        4) LOOK FOR THE TITLES, THE LINES WILL START WITH "menuentry 'the_name_of_OS' "
        5)COUNT HOW MANY "menuentry" ARE THERE AND CHANGE THE LINE:
            "set default="NUMBER OF THE DEFAULT" "
        6)PRESS "Esc" , PRESS ":x" , PRESS <Enter>
        7) Mazel Tov, dudes! Just restart your equipment and start a fiesta, because this baby is done.


PS.1: If you don't like the title or just want change the title of the OS in the boot loader, you can change it when you get in STEP 4).


PS.2: Remember that you have to count the boot order from 0. So if you have  3 OSs and you want to select the third in the list you'll put "2" in STEP 5).




CONSOLE KEYBOARD PROBLEM:


Well, i went looking all over Google and the guys had some real fancy stuff coming up to just resolve the problems, but as i'm not quite a specialist in the Linux-way of doing things, so i found a real simple way of editing the system files (that's why i was able to adjust the boot loader).


When you get to the file you want, just use:


      gedit <THE BLOODY FILE YOU WANT>


That's it, bros.


Hasta la vista, babes.
Tweet