UE4 Deck of Cards II

Completing our Card Interface C++ - Page 1

Now we are going to take off where we left with our previous C++ Visual Studio project Basic Class. In it we had the Card Class and Main all in the same page. Lets recreate this project and separate the Card class into its own .h and .cpp.

Otter dancing with a fish

You will need to install either Visual Studio Community 19 on the PC with C++ drivers or XCode on the mac. You will need to install the latest version of UE4 4.25.x by downloading the Epic Games Launcher. You will also need a GitHub account which is free to sign up for as we will be using version control.

1. Getting Set-Up

Lets start by getting a project and up and running. Lets add a material for a card and set it up in an unlit level with a camera.


Setting up our Dev Environment

Create a new C++ Windows Console Application project in Visual Studio nand pick a directory to save it in. Call the project ExtendingVSCardClass then press the Create Projects button.


Add Empty Class

We will take what we have done previously in Basic Class project and move it over. So in your new ExtendingVSCardClass project and press Project | Add Class and add a .h and .cpp called Card. Press the OK button:


Look at Card.h

VS should stub in an empty Card.h and Card.cpp. You .h should look like this:


Copy .h from FunctsTemlatesClasses

Now go and open BasicClass.cpp (from the FunctionsTeamplatesClasses project) and cut and paste the Card class declaration and paste it into Card.h like so:


Copy Card.cpp Definitions

Now copy and paste all the class definitions to the Card.cpp file. Leave the Main function to put in the project main cpp.


Add Main Loop

Now copy Main.cpp content to ExtendingVSCardClass.cpp. Also at the top add a reference to the new card class by adding #include "Card.h" and then for cout add using std::cout;.


Compile and Run

Compile and run and it should look EXACTLY like the Basic Class project did when we left off.