The optional repeat level option defines how many times the entire level should repeat itself before ending.
{
"opts": {
"repeat": number >= -1
}
}
Values #
-1
The level repeats indefinitely. Use this value for levels that should end only when the player runs out of lives.
N > 0
The level repeats N times.
Example Level JSON #
Infinite repititions #
{
"items": [
{
"type": "chunk",
"data": {
"10": [ {"key": "b", "gridY": 50} ]
}
}
],
"opts": {"repeat": -1}
}
This spawns bombs indefinitely until the player runs out of lives
Finite repititions #
{
"items": [
{
"type": "chunk",
"data": {
"10": [ {"key": "c", "gridY": 50} ]
}
}
],
"opts": {
"repeat": 9,
"winCriteria": {"type": "collect-all-coins"}
}
}
This spawns 10 coins (initial iteration, plus 9 repetitions) and ends after the final spawned coin passes by the player. The game over modal then specifies how many coins (x/10) the player collected.