Glue:GlueVault:Component Pages:PlatformerCharacterBase:Introduction

Introduction

This page shows how to perform setup and common tasks with the PlatformerCharacterBase entity.

Adding the Platformer Entity to your project

To add the PlatformerCharacterBase to your project:

  1. Download the Entity from GlueVault
  2. Import the Entity into your project
  3. Create a Screen
  4. Add a ShapeCollection to your Screen to act as the collision for the level
  5. Add an instance of the PlatformerCharacterBase Entity into the Screen
  6. Add the following code to your Screen’s CustomActivity

For more information on the CollideAgainst method, see this page.

Controlling the Entity

The PlatformerCharacterBase entity sets its controls to use the first Xbox360GamePad (if it is plugged in) and if not then it uses the Keyboard. If using an Xbox360GamePad you can move the entity with the left analog stick and jump with the A button. If using the keyboard you can move the entity with the left and right arrow keys and jump with the Space key.

The input code is set by assigning the PlatformerCharacterBase’s JumpInput and HorizontalInput. These properties are assigned in the entity’s CustomInitialize but they can be changed at any time.

The JumpInput property is a FlatRedBall.Input.IPressableInput. For more information on assigning JumpInput see the IPressableInput page.

The HorizontalInput property is a FlatRedBall.Input.I1DInput. For more information on assigning the HorizontalInput see the I1DInput page.

Setting variables in Glue

PlatformerCharacterBase provides two ways of modifying the behavior of the PlatformerCharacterBase. The first is to set the various MovementValue variables on the Entity. The PlatformerCharacterBase comes with a few sets of variables which let you quickly change between varaibles.

To change variable values:

  1. Expand the PlatformerCharacterBase Entity.
  2. Click on the Variables item. You should see all modifiable variables:PlatformerEntityVariablesInGlue.PNG
  3. Change the GroundMovement variable from ImmediateVelocityOnGround to AccelerationOnGround:ChangeGroundPlatformerVariables.png
  4. Change the other two values to use the corresponding “Acceleration” variables:AllAccelerationVariables.PNG

Now if you play the game you will see that the character uses acceleration when accelerating horizontally.

The purpose of this is not just to allow you to easily switch between two presets, but to also allow you to create additional entries in the CSV for an unlimited number of sets of coefficients.