The character action allows you to display a character's sprite. For other kind of images, take a look at the show image action.
Action ID: Show::Character
Reversible: Yes
Requires User Interaction: No
Character Definition
Characters must be defined before they can be shown. Each character has a unique identifier used in scripts:
monogatari.characters({'e':{name:'Evelyn',color:'#00bfff',directory:'evelyn',// Subdirectory in assets/characters/sprites:{normal:'normal.png',happy:'happy.png',sad:'sad.png'}}});
Character Properties
Property
Description
name
Display name shown in the text box
color
Color for the character's name (hex, rgb, or rgba)
directory
Subdirectory within assets/characters/ for sprite images
sprites
Object mapping sprite identifiers to image filenames
Face
Optional side image shown when the character speaks
Side
Optional object mapping side image identifiers for dialog expressions
Syntax
Positions
The at <position> clause sets where the character appears on screen. If omitted, defaults to center.
Common positions (CSS classes):
left - Left side of the screen
center - Center of the screen (default)
right - Right side of the screen
Custom positions can be defined via CSS.
Properties
These are special properties/classes that can be used when showing a character:
Character sprites that have been preloaded are automatically cached for faster display. When showing a character, the engine checks for cached sprites before loading from disk.
'show character e normal with fadeIn duration 20s'
'show character e normal at left',
'show character e normal at right with move transition 6s'
'show character e normal with end-fadeOut',
'show character e happy with fadeIn'
monogatari.script({
'Start': [
'show character e normal at left with fadeIn',
'e Hello there!',
'show character e happy at center with move transition 1s',
'e I moved to the center!',
'show character e normal with end-fadeOut',
'show character e sad with fadeIn duration 2s',
'e Now I\'m sad...',
'hide character e with fadeOut'
]
});