Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 65

MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
08/06/12 05:11 PM (13 years ago)

Game Center trouble

Hey, I've being struggling with this for a while. In need of help. I followed the great tutorial fond on BuzzTouch, I was able to follow all steps with no problem, but when I run the app, nothing happens regarding the Game Center. And I do have an alert in BT_screen_quiz.m @imprementation BT_screen_quiz - incomplete implementation. I first time i tried it a month or so ago, I got a lot of errors but I did get the gamecenter login pop up, but now, no errors and no nothing... Cheers.
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
08/06/12 05:55 PM (13 years ago)
Hmm. Does it open up in the simulator?
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
08/06/12 06:02 PM (13 years ago)
No it doesn't open in the simulator. And I found that the app tends To freeze now... Weird
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
08/06/12 06:08 PM (13 years ago)
Hmm... Not much to go off on, can you post the two source files?
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
08/07/12 01:28 AM (13 years ago)
Yes of course, here they are: /* * Copyright 2011, David Book, buzztouch.com * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice which includes the * name(s) of the copyright holders. It must also retain this list of conditions and the * following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of David Book, or buzztouch.com nor the names of its contributors * may be used to endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "iAd/ADBannerView.h" #import "BT_item.h" #import <GameKit/Gamekit.h> #import "GameCenterManager.h" @class GameCenterManager; @interface BT_viewController : UIViewController <UIAlertViewDelegate, ADBannerViewDelegate, ADBannerViewDelegate, UIActionSheetDelegate, GKLeaderboardViewControllerDelegate, GKAchievementViewControllerDelegate, GameCenterManagerDelegate>{ GameCenterManager *gameCenterManager; int64_t currentScore; NSString* currentLeaderBoard; IBOutlet UILabel *currentScoreLabel; BT_item *screenData; UIView *progressView; /* iAd Views */ UIView *adView; id adBannerView; BOOL adBannerViewIsVisible; BOOL hasStatusBar; BOOL hasNavBar; BOOL hasToolBar; } @property (nonatomic, retain) BT_item *screenData; @property (nonatomic, retain) UIView *progressView; @property (nonatomic, retain) UIView *adView; @property (nonatomic, retain) id adBannerView; @property (nonatomic) BOOL adBannerViewIsVisible; @property (nonatomic) BOOL hasStatusBar; @property (nonatomic) BOOL hasNavBar; @property (nonatomic) BOOL hasToolBar; @property (nonatomic, retain) GameCenterManager *gameCenterManager; @property (nonatomic, assign) int64_t currentScore; @property (nonatomic, retain) NSString* currentLeaderBoard; @property (nonatomic, retain) UILabel *currentScoreLabel; -(id)initWithScreenData:(BT_item *)theScreenData; -(void)showProgress; -(void)hideProgress; -(void)navLeftTap; -(void)navRightTap; -(void)showAudioControls; -(void)showAlert:(NSString *)theTitle:(NSString *)theMessage:(int)alertTag; -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex; -(void)createAdBannerView; -(void)showHideAdView; -(void)bannerViewDidLoadAd:(ADBannerView *)banner; -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error; -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; -(void)didReceiveMemoryWarning; @end
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
08/07/12 01:28 AM (13 years ago)
and here is viewcontroller.m /* * Copyright 2011, David Book, buzztouch.com * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice which includes the * name(s) of the copyright holders. It must also retain this list of conditions and the * following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of David Book, or buzztouch.com nor the names of its contributors * may be used to endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import "iAd/ADBannerView.h" #import "JSON.h" #import "ltyh_appDelegate.h" #import "BT_item.h" #import "BT_debugger.h" #import "BT_viewControllerManager.h" #import "BT_viewUtilities.h" #import "BT_viewController.h" #import "AppSpecificValues.h" #import "GameCenterManager.h" @implementation BT_viewController @synthesize progressView, screenData; @synthesize adView, adBannerView, adBannerViewIsVisible; @synthesize hasStatusBar, hasNavBar, hasToolBar; @synthesize gameCenterManager; @synthesize currentScore; @synthesize currentLeaderBoard; @synthesize currentScoreLabel; //GameCenter View Did Load - (void)viewDidLoad { [super viewDidLoad]; self.currentLeaderBoard = kLeaderboardID; // self.currentScore = 0; if ([GameCenterManager isGameCenterAvailable]) { self.gameCenterManager = [[[GameCenterManager alloc] init] autorelease]; [self.gameCenterManager setDelegate:self]; [self.gameCenterManager authenticateLocalUser]; } else { // The current device does not support Game Center. } } - (IBAction) showLeaderboard { GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != NULL) { leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; [self presentModalViewController: leaderboardController animated: YES]; } } - (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController { [self dismissModalViewControllerAnimated: YES]; [viewController release]; } - (IBAction) showAchievements { GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init]; if (achievements != NULL) { achievements.achievementDelegate = self; [self presentModalViewController: achievements animated: YES]; } } - (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController; { [self dismissModalViewControllerAnimated: YES]; [viewController release]; } //GameCenter View Did Unload - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; self.gameCenterManager = nil; self.currentLeaderBoard = nil; self.currentScoreLabel = nil; } - (void)dealloc { [gameCenterManager release]; [currentLeaderBoard release]; [currentScoreLabel release]; [super dealloc]; } //initWithScreenData -(id)initWithScreenData:(BT_item *)theScreenData{ if((self = [super init])){ [BT_debugger showIt:self:@"INIT"]; //set screen data [self setScreenData:theScreenData]; } return self; } //show progress -(void)showProgress{ [BT_debugger showIt:self:@"showProgress"]; //show progress view if not showing if(progressView == nil){ progressView = [BT_viewUtilities getProgressView:@""]; [self.view addSubview:progressView]; } } //hide progress -(void)hideProgress{ [BT_debugger showIt:self:@"hideProgress"]; //remove progress view if already showing if(progressView != nil){ [progressView removeFromSuperview]; progressView = nil; } } //left button -(void)navLeftTap{ [BT_debugger showIt:self:@"navLeftTap"]; //handle "left" transition [BT_viewControllerManager handleLeftButton:screenData]; } //right button -(void)navRightTap{ [BT_debugger showIt:self:@"navRightTap"]; //handle "right" transition [BT_viewControllerManager handleRightButton:screenData]; } //show audio controls -(void)showAudioControls{ [BT_debugger showIt:self:@"showAudioControls"]; //appDelegate ltyh_appDelegate *appDelegate = (ltyh_appDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate showAudioControls]; } //show alert -(void)showAlert:(NSString *)theTitle:(NSString *)theMessage:(int)alertTag{ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:theTitle message:theMessage delegate:self cancelButtonTitle:NSLocalizedString(@"ok", "OK") otherButtonTitles:nil]; [alertView setTag:alertTag]; [alertView show]; [alertView release]; } //"OK" clicks on UIAlertView - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ [BT_debugger showIt:self:[NSString stringWithFormat:@"alertView:clickedButtonAtIndex: %i", buttonIndex]]; //handles OK click after emailing an image from BT_screen_imageEmail if([alertView tag] == 99){ [self.navigationController popViewControllerAnimated:YES]; } //handles OK click after sharing from BT_screen_shareFacebook or BT_screen_shareTwitter if([alertView tag] == 199){ [self navLeftTap]; } } //////////////////////////////////////////// //Ad Size Methods //createAdBannerView -(void)createAdBannerView{ Class classAdBannerView = NSClassFromString(@"ADBannerView"); if(classAdBannerView != nil){ [BT_debugger showIt:self:[NSString stringWithFormat:@"createiAdBannerView: %@", @""]]; self.adView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; self.adView.autoresizingMask = (UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth); [self.adView setTag:94]; self.adBannerView = [[[classAdBannerView alloc] initWithFrame:CGRectZero] autorelease]; [self.adBannerView setDelegate:self]; [self.adBannerView setTag:955]; if(UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) { [adBannerView setCurrentContentSizeIdentifier: ADBannerContentSizeIdentifierLandscape]; }else{ [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait]; } [self.adView setFrame:[BT_viewUtilities frameForAdView:self:screenData]]; [adView setBackgroundColor:[UIColor clearColor]]; [self.adView addSubview:self.adBannerView]; [self.view addSubview:adView]; [self.view bringSubviewToFront:adView]; } } //showHideAdView -(void)showHideAdView{ [BT_debugger showIt:self:[NSString stringWithFormat:@"showHideAdView: %@", @""]]; if(adBannerView != nil){ //we may need to change the banner ad layout if(UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) { [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape]; }else{ [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait]; } [UIView beginAnimations:@"positioniAdView" context:nil]; [UIView setAnimationDuration:1.5]; if(adBannerViewIsVisible){ [self.adView setAlpha:1.0]; }else{ [self.adView setAlpha:.0]; } [UIView commitAnimations]; } } //banner view did load... -(void)bannerViewDidLoadAd:(ADBannerView *)banner{ [BT_debugger showIt:self:[NSString stringWithFormat:@"iAd bannerViewDidLoadAd%@", @""]]; if(!adBannerViewIsVisible) { adBannerViewIsVisible = YES; [self showHideAdView]; } } //banner view failed to get add -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{ [BT_debugger showIt:self:[NSString stringWithFormat:@"iAd didFailToReceiveAdWithError: %@", [error localizedDescription]]]; if (adBannerViewIsVisible){ adBannerViewIsVisible = NO; [self showHideAdView]; } } //shouldAutorotateToInterfaceOrientation -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return NO; } //didReceiveMemoryWarning -(void)didReceiveMemoryWarning{ [BT_debugger showIt:self:[NSString stringWithFormat:@"appDelegate didReceiveMemoryWarning%@", @""]]; } @end
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
08/07/12 01:40 AM (13 years ago)
Apparently the Game Center is activated in the device itself, but not the simulator. But it still frezes, this is what I get: /* * Copyright 2011, David Book, buzztouch.com * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice which includes the * name(s) of the copyright holders. It must also retain this list of conditions and the * following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of David Book, or buzztouch.com nor the names of its contributors * may be used to endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { //return ltyh_appDelegate as UIApplicationMain (not using any .xib files) NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal= UIApplicationMain(argc,argv,@"UIApplication",@"ltyh_appDelegate"); [pool release]; return retVal; } After answering the last quiz question it either freezes or quites the app, I get this: showIncorrect 2012-08-07 09:33:58.321 ltyh[910:707] BT_screen_quiz: transitionPoints 2012-08-07 09:34:00.324 ltyh[910:707] BT_screen_quiz: quizEnded 2012-08-07 09:34:00.353 ltyh[910:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSThread initWithTarget:selector:object:]: target does not implement selector (*** -[BT_screen_quiz sendQuizResultsToURL])' *** First throw call stack: (0x35ae288f 0x37e89259 0x35ae2789 0x35ae27ab 0x35571731 0x35571689 0x7ad3f 0x355fc933 0x35ab6a33 0x35ab6699 0x35ab526f 0x35a384a5 0x35a3836d 0x376d4439 0x33544cd5 0x33a03 0x27d4) terminate called throwing an exception(lldb) Without the game center integration it works fine. Thank you
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
08/07/12 01:54 AM (13 years ago)
And now, without making any change, the buid fails, with this error: Ld /Users/madrod/Library/Developer/Xcode/DerivedData/ltyh-bwbucyhmsrlcjecedzokzgrfumyo/Build/Products/Debug-iphonesimulator/ltyh.app/ltyh normal i386 cd "/Users/madrod/Dropbox/App Dev/IOS/LTYH" setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -L/Users/madrod/Library/Developer/Xcode/DerivedData/ltyh-bwbucyhmsrlcjecedzokzgrfumyo/Build/Products/Debug-iphonesimulator -F/Users/madrod/Library/Developer/Xcode/DerivedData/ltyh-bwbucyhmsrlcjecedzokzgrfumyo/Build/Products/Debug-iphonesimulator -filelist /Users/madrod/Library/Developer/Xcode/DerivedData/ltyh-bwbucyhmsrlcjecedzokzgrfumyo/Build/Intermediates/ltyh.build/Debug-iphonesimulator/ltyh.build/Objects-normal/i386/ltyh.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=30000 -framework GameKit -framework CFNetwork -lxml2.2 -framework CoreAudio -framework CoreLocation -framework Foundation -framework SystemConfiguration -weak_framework UIKit -framework MobileCoreServices -framework AVFoundation -weak_framework MessageUI -framework MapKit -weak_framework MediaPlayer -framework CoreGraphics -framework QuartzCore -weak_framework iAd -o /Users/madrod/Library/Developer/Xcode/DerivedData/ltyh-bwbucyhmsrlcjecedzokzgrfumyo/Build/Products/Debug-iphonesimulator/ltyh.app/ltyh Undefined symbols for architecture i386: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) OMG. :-) Cheers
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
08/15/12 03:25 PM (13 years ago)
Got it working, thanks
 
Jerry
Aspiring developer
Profile
Posts: 51
Reg: Aug 07, 2012
Dallas
3,160
like
01/01/13 11:12 PM (13 years ago)
Hi MadRod, I'm getting the same error as you did above. How did you get it working? Thanks.
 
Jerry
Aspiring developer
Profile
Posts: 51
Reg: Aug 07, 2012
Dallas
3,160
like
01/01/13 11:28 PM (13 years ago)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.