This represents a Coin or a type of Gem (Green, Red, Blue). From the game’s perspective, coins and gems are the same kind of spawnable object (“coin”), but a “coin” or “green/red/blue gem” are different types of “coins”.
A default coin awards 1 point, green and red gems award 2 points, and blue gems award 3 points.
The type of “coin” that actually spawns can be controlled by the “probs” or “type” value.
Spawnable Object data #
{
"key": "c",
"gridY": <GridY>,
"probs": <Array of CoinType probabilities>, (optional)
"type": <CoinType> (optional)
}
Data Fields #
gridY #
The GridY position to spawn this object (see Coordinate System)
probs (optional) #
Defines the probabilities that a specific coin type will spawn.
Probablities are defined like this:
"probs": [
{ "value": "default", "p": 0.4 },
{ "value": "green", "p": 0.1 },
{ "value": "red", "p": 0.2 },
{ "value": "blue", "p": 0.3 }
]
-
value – defines the type of coin/gem that is spawned
- options:
default
,green
,red
,blue
- options:
-
p – probability that the coin will spawn with the given type. All values of
p
within a singleprobs
array must sum to 1.0
In this example, this coin object will have a 40% chance to spawn as a default coin, 10% chance to spawn as a green gem, 20% chance to spawn as a red gem, and a 30% chance to spawn as a blue gem. The final type is chosen at spawn time based on the defined probabilities.
type (optional) #
Defines the specific type of coin/gem that will spawn, instead of randomly through probabilities.
options: default
, green
, red
, blue
Note that only one of probs
or type
should be present for a single coin spawnable object. Including both will result in an error message.
Example Level JSON #
{
"items": [
{
"type": "chunk",
"data": {
"0": [
{
"key": "c",
"gridY": 50,
"probs": [
{"value": "default", "p": 0.4},
{"value": "green" , "p": 0.1},
{"value": "red" , "p": 0.2},
{"value": "blue" , "p": 0.3}
]
}
],
"25": [
{"key": "c", "gridY": 30, "type": "default"},
{"key": "c", "gridY": 40, "type": "green" },
{"key": "c", "gridY": 50, "type": "red" },
{"key": "c", "gridY": 60, "type": "blue" }
]
}
}
]
}