Create hero in map
Once your first map exists, the next step is to put the player inside it and assign a spritesheet.Spawn the player on connection
In your player hooks:- Sends the player to
simplemap - Places the player at the Tiled point named
start, if it exists - Uses the
herospritesheet on the client
maxHp are available immediately on the client.
To use the automatic start position, create an object layer in Tiled, add a point,
and set its name to start. You can also target any named point explicitly:
Initialize default stats only when needed
Useplayer.initializeDefaultStats() if you want RPGJS to define the default
parameter curves (maxHp, maxSp, str, int, dex, agi) and initialize
HP/SP from those values.
This is useful if:
- you define the starting stats directly in your game
- you rely on RPGJS built-in default values
- you want HP/SP and parameter displays to be ready on the client as soon as the game starts
player.initializeDefaultStats() after loading player data from:
- your own database
- a save slot
- a snapshot
player.applyDefaultParameters().
Use onStart() when the game begins after a GUI
If your game starts after a title screen or another GUI interaction, initialize the
default stats in onStart() instead of onConnected().
onStart() is executed after a GUI interaction returns data.id === 'start'.
Make sure the hero graphic exists
The hero identifier must exist in your client configuration: