Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

Character Script

skellypupper edited this page May 31, 2023 · 14 revisions
Empty Script

Example character scripts can be found here.

// required
function create() {}
// optional
function getIcon() return "face";
function createPost() {}
function update(elapsed:Float) {}
function dance() {}

How to use

Make a character script at characters/<charactername>/init.hxs, you can also place your character assets in the <charactername> folder.

If the create callback doesn't finish successfully, a bf will spawn in your character's place.

Variables

  • char: The current character class (extended FlxSprite), used to edit character data.
  • char.iconName: The name of the icon you want to use for the character. If unset it uses char.curCharacter.
  • char.deadData: A data set for the game over screen.
    • char.deadData.char: The name of the character to use on the game over screen, if unset it uses char.curCharacter.
    • char.deadData.sound: The string path to the death sound to use on the game over screen.
    • char.deadData.music: The string path to the death song used on the game over screen.
    • char.deadData.end: The string path to the concluding sound for the game over screen.
    • char.deadData.bpm: BPM for the death song used on the game over screen.
  • char.bopSpeed: How many beats it takes for the character to dance. If the character is detected having danceLeft and danceRight animations, this will be set to 1.
  • char.stopAnims: If true, the character will not respond to any new animation calls.
  • char.stopSinging: If true, the character will not respond to any singing animation calls.
  • char.stopDancing: If true, the character will not respond to any dancing calls (if animation includes "dance" or is "idle").
  • char.displaceData: A data set with x, y, camX, camY. x and y changes will displace the character sprite, camX and camY will displace where the camera is when focused on the character.
  • Paths: A custom paths instance that only reads for files inside the characters/<charactername> directory.
  • _Paths: The global paths instance.

Callbacks

Required

  • create(): This is where you create character.

Optional

  • getIcon(): Used to fetch an icon if your character doesn't have one that matches.
  • createPost(): Called after the character class is created.
  • update(elapsed:Float): Called every frame.
  • dance(): Called when the PlayState calls Character#dance. If used, it completely overrides the original dance function for the target character.