Creating and implementing the GameTile Interface class

As explained in the introduction to this section, we will start by creating the GameTile interface class for our SlidingTiles game, which will be used to create instances of each game tile that will be displayed in the gameboard View control we added to our ViewController contained in our Storyboard.

Let's start by creating the IGameTile interface for our SlidingTiles app by performing the following steps:

  1. Ensure that the SlidingTiles solution is open in the Visual Studio for Mac IDE.
  2. Next, right-click on the SlidingTiles project and choose Add|New Folder from the pop up menu, as shown in the following screenshot:
Creating a new Folder within the SlidingTiles solution
  1. Then, enter Interfaces for the name of the new folder to be created, then right-click on the Interfaces folder and choose Add|New File... from the pop up menu, as shown in the following screenshot:
Creating a new Empty Interface within the Interfaces folder
  1. Next, choose the Empty Interface option under the General section and enter IGameTile for the name of the new Interface file to be created, as shown in the following screenshot:
Creating the IGameTile Interface
  1. Next, click on the New button to allow the wizard to proceed and create the new file, as shown in the preceding screenshot. Now that we have created our IGameTile interface file, we can proceed with implementing the required code for our Interface class.
  1. Locate and open the IGameTile.cs file, which is located as part of the SlidingTiles group, ensure that it is displayed in the code editor, and enter the following code snippet:
     //
// IGameTile.cs
// Interface class for the GameTile class
//
// Created by Steven F. Daniel on 24/04/2018.
// Copyright © 2018 GENIESOFT STUDIOS. All rights reserved.
//
using UIKit;

namespace SlidingTiles.Interfaces
{
public interface IGameTile
{
UIImage DrawTileText(UIImage uiImage, string sText,
UIColor textColor, int iFontSize);
}
}

Let's take a look at what we covered in the preceding code snippet:

  1. First, we started by including a reference to the UIKit namespace that will be used to allow us to access iOS-specific user interface components, such as UIButton, UIView, UIImageView, and so on
  2. Next, we declared an instance method called DrawTileText, which contains a number of parameters that will be used to draw text onto a specified image
  3. Then, we declared a uiImage parameter that is the image that we want to use
  4. Next, we declared an sText parameter that will be the text we want to place in the image
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.148.210