-
Book Overview & Buying
-
Table Of Contents
Unreal Development Kit Game Programming with UnrealScript: Beginner's Guide
By :
Time to pass some variables around! Let's start with the PostBeginPlay function in our AwesomeEnemySpawner class.
We haven't defined the PostBeginPlay function for our AwesomeEnemySpawner class, so let's do it now, and let's add an int to the function parameters:
function PostBeginPlay(int MyInt)
{
}Compile the code. Uh oh, an error right out of the gate:
Error, Redefinition of 'function PostBeginPlay' differs from original; different number of parameters
This is the most important thing to remember about function parameters. Once a function is defined, if it's ever used in a subclass, then it must have the exact same number and type of parameters as the original. The names of the variables don't have to be the same, but if the original function has a bool and an int, any subclasses must have a bool and an int in their parameters.
Let's take a look at an example of this. We've been using the Tick function a lot. If we look in Actor.uc where it's declared...
Change the font size
Change margin width
Change background colour