“Match App - Flag and Zodiac - iPhone & iPad App” Documentation by “Giorgio Minissale” v1.0


“Match App - Flag and Zodiac - Universal App”

Created: 7/31/2014
By: Giorgio Minissale
Email: giorgio.minissale@devco.it
Download Match App - Flag and Zodiac

Thank you for purchasing my code. If you have any questions that are beyond the scope of this help file, please feel free to email. Thanks so much!


Table of Contents

  1. Description
  2. App structure
  3. Change Graphics Tiles
  4. Shuffle Tiles
  5. AD integration: iAd, RevMob
  6. Configure Appirater
  7. Game Center integration

A) Description - top

Through this application you will be able to simply create your own "Memory Game - Match App" . Just change the graphics of the game and update the IDs of the external services such as Ad RevMob and Appirater Review. The features of the game "Match App" are: Match App - Flag and Zodiac its a free game for iPhone and iPad. Find the pairs as quickly as possible and with the least number of moves. Two levels of play:

  1. Match flags
  2. Match signs of the zodiac
Two game modes for each level, play against the time or make the fewest number of moves. World ranking with Game Center!

The App publishes scores on Game Center , divided into 4 leaderboards.

Completing the game 2 different types of Ad:

  1. Apple iAd [banner at the bottom of the first View of the app ]
  2. Ad RevMob [banner fullscreen] & banner at the bottom of game

B) App Structure - top

The first view allows us to select the gameplay at which to start playing or see charts of the top players on Game Center. Banner at the bottom, above the label with a summary of our best score.

Match App iPhone

Match App iPhone

Open Game Center from Home

Match App Game Center iPhone


C) Change Graphics Tiles - top

Graphic Tiles

Match App Images

The sizes of the images for the cards are of two types:

  1. iPhone: 50x50 px and 100x100 px for retina display
  2. iPad: 100x100 px and 200x200 px for retina display
Are placed inside a NSMutableArray, the code recognizes if the app runs on the iPhone or iPad via the following conditional statement:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        self.tiles = [[NSMutableArray alloc]initWithObjects:
                      [UIImage imageNamed:@"iPad_icons_01.png"],
                      [UIImage imageNamed:@"iPad_icons_01.png"],
                      [UIImage imageNamed:@"iPad_icons_02.png"],
                      [UIImage imageNamed:@"iPad_icons_02.png"],
                      [UIImage imageNamed:@"iPad_icons_03.png"],
                      [UIImage imageNamed:@"iPad_icons_03.png"],
                      [UIImage imageNamed:@"iPad_icons_04.png"],
                      [UIImage imageNamed:@"iPad_icons_04.png"],
                      [UIImage imageNamed:@"iPad_icons_05.png"],
                      [UIImage imageNamed:@"iPad_icons_05.png"],
                      [UIImage imageNamed:@"iPad_icons_06.png"],
                      [UIImage imageNamed:@"iPad_icons_06.png"],
                      [UIImage imageNamed:@"iPad_icons_07.png"],
                      [UIImage imageNamed:@"iPad_icons_07.png"],
                      [UIImage imageNamed:@"iPad_icons_08.png"],
                      [UIImage imageNamed:@"iPad_icons_08.png"],
                      [UIImage imageNamed:@"iPad_icons_09.png"],
                      [UIImage imageNamed:@"iPad_icons_09.png"],
                      [UIImage imageNamed:@"iPad_icons_10.png"],
                      [UIImage imageNamed:@"iPad_icons_10.png"],
                      [UIImage imageNamed:@"iPad_icons_11.png"],
                      [UIImage imageNamed:@"iPad_icons_11.png"],
                      [UIImage imageNamed:@"iPad_icons_12.png"],
                      [UIImage imageNamed:@"iPad_icons_12.png"],
                      [UIImage imageNamed:@"iPad_icons_13.png"],
                      [UIImage imageNamed:@"iPad_icons_13.png"],
                      [UIImage imageNamed:@"iPad_icons_14.png"],
                      [UIImage imageNamed:@"iPad_icons_14.png"],
                      [UIImage imageNamed:@"iPad_icons_15.png"],
                      [UIImage imageNamed:@"iPad_icons_15.png"],
                      nil];
    }
    else
    {
        self.tiles = [[NSMutableArray alloc]initWithObjects:
                      [UIImage imageNamed:@"icons_01.png"],
                      [UIImage imageNamed:@"icons_01.png"],
                      [UIImage imageNamed:@"icons_02.png"],
                      [UIImage imageNamed:@"icons_02.png"],
                      [UIImage imageNamed:@"icons_03.png"],
                      [UIImage imageNamed:@"icons_03.png"],
                      [UIImage imageNamed:@"icons_04.png"],
                      [UIImage imageNamed:@"icons_04.png"],
                      [UIImage imageNamed:@"icons_05.png"],
                      [UIImage imageNamed:@"icons_05.png"],
                      [UIImage imageNamed:@"icons_06.png"],
                      [UIImage imageNamed:@"icons_06.png"],
                      [UIImage imageNamed:@"icons_07.png"],
                      [UIImage imageNamed:@"icons_07.png"],
                      [UIImage imageNamed:@"icons_08.png"],
                      [UIImage imageNamed:@"icons_08.png"],
                      [UIImage imageNamed:@"icons_09.png"],
                      [UIImage imageNamed:@"icons_09.png"],
                      [UIImage imageNamed:@"icons_10.png"],
                      [UIImage imageNamed:@"icons_10.png"],
                      [UIImage imageNamed:@"icons_11.png"],
                      [UIImage imageNamed:@"icons_11.png"],
                      [UIImage imageNamed:@"icons_12.png"],
                      [UIImage imageNamed:@"icons_12.png"],
                      [UIImage imageNamed:@"icons_13.png"],
                      [UIImage imageNamed:@"icons_13.png"],
                      [UIImage imageNamed:@"icons_14.png"],
                      [UIImage imageNamed:@"icons_14.png"],
                      [UIImage imageNamed:@"icons_15.png"],
                      [UIImage imageNamed:@"icons_15.png"],
                      nil];
    }


D) Shuffle Tiles - top

Below is the method that handles shuffle the cards, can be found in the files GameFlagViewController.m line 185:

- (void)shuffleTiles
{
    int tileCount = (int) [self.tiles count];
    
    for (int tileID = 0; tileID < (tileCount/2); tileID++)
    {
        [self.shuffledTiles addObject:[NSNumber numberWithInt:tileID]];
        [self.shuffledTiles addObject:[NSNumber numberWithInt:tileID]];
    }
    
    for (NSUInteger i = 0; i < tileCount; ++i) {
        NSInteger nElements = tileCount - i;
        NSInteger n = (arc4random() % nElements) + i;
        [self.shuffledTiles exchangeObjectAtIndex:i withObjectAtIndex:n];
        [self.tiles exchangeObjectAtIndex:i withObjectAtIndex:n];
    }
}

This app contains two different types of AD:

  1. Apple iAd [banner at the bottom of the app, first screen]
  2. Ad RevMob [banner fullscreen & banner at the bottom of the game view controller] RevMob site

  3. The iAd banner is shown in all the movies at the bottom of the app, is initialized in the class "ViewController".

    Match App iAD


    Configure RevMob

    1. Step 1: Create a new RevMob account, go to www.revmobmobileadnetwork.com
    2. Step 2: After login, go to "Apps" section and add a new App, in this way you will have the key to your app
    3. Step 3: Download the latest version of the revmob SDK, open the SDK directory drag and drop the directory RevMobAds.framework inside one file group of your project on XCode (usually, "Frameworks").
    4. Step 4: To use the RevMobAds.framework, just import it (in .h or .m files) in every class you want to use it
      #import RevMobAds/RevMobAds.h
    5. Step 5: Inside didFinishLaunchingWithOptions on AppDelegate, add
      [RevMobAds startSessionWithAppID:@"copy your RevMob App ID here"];
    6. Step 6: Add fullscreen ad at start of the app:
      - (void)applicationDidBecomeActive:(UIApplication *)application {
          [[RevMobAds session] showFullscreen];
      }
      
    7. Step 7: Add banner
      [[RevMobAds session] showBanner];
      on viewDidLoad

    For more information, go to official: SDK iOS RevMob


    F) Configure Appirater - top

    Appirater is a class that you can drop into any iPhone/iPad app that will help remind your users to review your app on the App Store.

    Settings, inside AppDelegate.m, kAppiraterAppID it's your App ID provided by itunes connect.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.
        [RevMobAds startSessionWithAppID:kRevMobAppID];
    //    [RevMobAds session].testingMode = RevMobAdsTestingModeWithAds;
        
        
        // Appirater
        [Appirater setAppId:kAppiraterAppID];
        [Appirater setDaysUntilPrompt:10];
        [Appirater setUsesUntilPrompt:3];
        [Appirater setSignificantEventsUntilPrompt:-1];
        [Appirater setTimeBeforeReminding:2];
        //[Appirater setDebug:YES];
        [Appirater appLaunched:YES];
        
        
        return YES;
    }
    

    G) GameCenter integration - top

    How to create leaderboards and achievements:

    1. Step 1 : log in into itunesConnect.apple.com (you need a publisher account)
    2. Step 2: click on “Manage your App”
    3. Step 3: click “Add new App”
    4. Step 4: after creating the app, click on “Manage Game Center”! Step 5: click “Enable for single Game”
    5. Step 6: starts with “Leaderboards”

    Leaderboards in my app is a “Top Score” ranking, divided into three tables, one for each level of difficulty, and one unique Fruit Leaderboard

    Leaderboards Step

    1. Step 1 : click “Add Leaderboard”
    2. Step 2: choose “Single Leaderboard”
    Fill out the form in this way:

    1. Leaderboard Reference Name : internal name, “Best Score Flag”! Leaderboard ID : com.yourdomain.appName.topscore
    2. Score Format Type : in this app I need “Integer”
    3. Score Submission Type: “Best Score”
    4. Sort Order: “Low to High”
    5. Score Range : 0 To 9999999

    Add one or more language on “Leaderboard Localization” :! Click “Add Language”, select “English” .

    1. Name : Best Score Flag
    2. Score Format : Integer
    3. Score Format Suffix (singular) : Move
    4. Score Format Suffix (plural) : Moves
    5. Image : (Optional 512 x 512 or 1024 x 1024 image)

    Add Leaderboard ID on this file GameFlagViewController.m:

    - (void) winner
    {
        [bestime invalidate];
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        int highScore = (int) [defaults integerForKey:@"highScore_flag"];
        int besttimeEver = (int)[defaults integerForKey:@"bestime_flag"];
        if ([levelType isEqualToString:@"MOVES"])
        {
            if ((highScore == 0) && (self.guessCounter > 0)) {
                [defaults setObject:[NSNumber numberWithInt:(int)self.guessCounter] forKey:@"highScore_flag"];
                self.gameScoreLabel.text = [NSString stringWithFormat:@"New best score! Guesses: %ld", (long)self.guessCounter];
                [[GameKitHelper sharedGameKitHelper] reportScore:(int)self.guessCounter forLeaderboardID:kLeaderboardFlagMoves];
            }
            else if (highScore > self.guessCounter)
            {
                [defaults setObject:[NSNumber numberWithInt:(int)self.guessCounter] forKey:@"highScore_flag"];
                self.gameScoreLabel.text = [NSString stringWithFormat:@"New best score! Guesses: %ld", (long)self.guessCounter];
                [[GameKitHelper sharedGameKitHelper] reportScore:(int)self.guessCounter forLeaderboardID:kLeaderboardFlagMoves];
            }
            else
                self.gameScoreLabel.text = [NSString stringWithFormat:@"Game over. Guesses: %ld", (long)self.guessCounter];
        }
        else
        {
            if ((besttimeEver == 0) && (seconds > 0))
            {
                [defaults setObject:[NSNumber numberWithInt:seconds] forKey:@"bestime_flag"];
                [[GameKitHelper sharedGameKitHelper]reportScore:seconds forLeaderboardID:kLeaderboardFlagTime];
            }
            else if (besttimeEver > seconds) {
                // New record!
                [defaults setObject:[NSNumber numberWithInt:seconds] forKey:@"bestime_flag"];
                [[GameKitHelper sharedGameKitHelper]reportScore:seconds forLeaderboardID:kLeaderboardFlagTime];
            }
            else
                self.gameScoreLabel.text = [NSString stringWithFormat:@"Game over. Seconds: %d", seconds];
        }
    
    }


    Giorgio Minissale

    Go To Table of Contents