Class Game

Hierarchy

  • Game

Constructors

  • Returns Game

Properties

listener: Function
player: Player
serverConfig: {
    apiKey: any;
    eventId: any;
    spaceId: any;
} = ...

Type declaration

  • apiKey: any
  • eventId: any
  • spaceId: any

Methods

  • Pop up the countdown component, ready to start the game

    Example

    If the game needs a 5s countdown

    app.game.countDown(5000)
    

    Throws

    Error message

    Parameters

    • second: number

      countdown duration, milliseconds

    Returns Promise<boolean>

    If it is successfully sent to the server, it will return true. Otherwise it will return an error message

  • Send a notification that the game is finish

    Example

    If you want to send a game finish notification to the user with id 123

    app.game.finishGame('123')
    

    Throws

    Error message

    Parameters

    • pid: string

      specifies the id of the user who received the notification

    Returns Promise<boolean>

    If it is successfully sent to the server, it will return true. Otherwise it will return an error message

  • Initialize the game and create game-related listeners. Please consult the vland staff for the official game.

    Example

    If you wanna initialize a official race game.

    
    

    Throws

    Error message

    Parameters

    • config: {
          describe: string;
          icon: string;
          listener: Function;
          name: string;
      }

      game config, contains {name, describe, icon, listener}. listeneris a custom function.

      • describe: string
      • icon: string
      • listener: Function
      • name: string

    Returns Promise<boolean>

    If it is successfully sent to the server, it will return true. Otherwise it will return an error message

  • Send a notification that the game is ready to start

    Example

    If the game if ready.

    app.game.readyGame(code: 200, "Race game is ready!")
    

    If the game is not ready due to some bug.

    app.game.readyGame(code: 400, "Race game is not ready!")
    

    Throws

    Error message

    Parameters

    • code: number

      status of readiness

    • message: string

      text message of current status

    Returns Promise<boolean>

    If it is successfully sent to the server, it will return true. Otherwise it will return an error message

  • Send a notification that the game is stop

    Example

    If you want to send a game stop notification to the all users

    app.game.stopGame()
    

    Throws

    Error message

    Returns Promise<boolean>

    If it is successfully sent to the server, it will return true. Otherwise it will return an error message

  • Push updated leaderboard information

    Example

    If you wanna update the leaderboard.

    app.game.updateRankList([{pid: '123', time: 99999}])
    

    Throws

    Error message

    Parameters

    • rankInfo: [{
          pid: string;
          time: number;
      }]

      leaderboard information list, item contains {pid, time}. timeis milliseconds.

    • type: string

      custom leaderboard type, such as race, ox, etc.

    Returns Promise<boolean>

    If it is successfully sent to the server, it will return true. Otherwise it will return an error message

Generated using TypeDoc