Level Option – Speed

Table Of Contents

The optional speed level option defines the game speed multiplier on the default game speed.

{
  "opts": {
    "speed": <number > 0 and <= 3>
  }
}

By default (ie with a speed value of 1), game objects will move at a speed of (0.5 * gameWidth) pixels per second. In other words, an object at GridX=100 will take 2 seconds to reach GridX=0.

Values #

The number specified with the speed option will be multiplied to the default game speed, and must be greater than 0 and less than or equal to 3.

For example, "speed": 0.5 will make objects move at half speed: (0.5 * 0.5 * gameWidth) pixels per second.

"speed": 3 will make objects move at 3x the default speed: (3 * 0.5 * gameWidth) pixels per second.


Example Level JSON #

Slow #

{
  "items": [
    {
      "type": "chunk",
      "data": {
        "10": [
          {
            "key": "c",
            "gridY": 98
          }
        ]
      }
    }
  ],
  "opts": {
    "speed": 0.5,
    "repeat": -1
  }
}

Fast #

{
  "items": [
    {
      "type": "chunk",
      "data": {
        "10": [
          {
            "key": "c",
            "gridY": 98
          }
        ]
      }
    }
  ],
  "opts": {
    "speed": 2,
    "repeat": -1
  }
}