02 – Creating Sprite and Collision

Introduction

Even though Super Mario World is considered an old game, Mario has a lot of behaviors. In fact, Super Mario World is complex enough that a tutorial which implemented all functionality would be considerably longer than this one. Therefore, we’ll skip over a number of behaviors and instead focus on the following:

  • Idle
  • Walk
  • Run
  • Jump
  • Duck
  • Look up
  • Skid (Trying to turn around when running)

This list of behaviors will provide enough variety to explore how to create and manage a variety of animations and behavioral states.

Mario Files

For this tutorial we’ll be using the following image and .achx file.

https://github.com/vchelaru/FlatRedBall/raw/NetStandard/Samples/Platformer/Animations/PlatformerAnimations.achx

Download both files to the same folder. Drag+drop the PlatformerAnimations.acxh file into the Player Files folder. Both the .achx and .png will automatically be copied into the project (assuming you downloaded both files to the same folder).

Mario Sprite

Next we’ll add a Sprite and animate it.

  1. Select Player
  2. Click Add Object to Player in Quick Actions
  3. Select the Sprite type
  4. Click OK
  5. Set the Animation Chains to PlayerAnimations
  6. Set the Current Chain Name to CharacterWalkRight

Now our character is fully animated, but it does have an offset issue.

This is happening because the .achx file is set up (properly) to align the bottom animations with the origin of the entity. We need to adjust the offset of the rectangle. While we’re at it, we can also adjust the rectangle size.

These changes should fix the collision size and offset.

Conclusion

Our Player entity is now set up with a rectangle of the right size and referencing animations. Next we’ll add the logic for setting the animations using AnimationLayers.