@minecraft
    正在准备搜索索引...

    类 ScreenDisplay

    Contains information about user interface elements that are showing up on the screen.

    import { world, DimensionLocation } from '@minecraft/server';

    function setTitle(targetLocation: DimensionLocation) {
    const players = world.getPlayers();

    if (players.length > 0) {
    players[0].onScreenDisplay.setTitle('§o§6Fancy Title§r');
    }
    }
    import { world, DimensionLocation } from '@minecraft/server';

    function setTitleAndSubtitle(targetLocation: DimensionLocation) {
    const players = world.getPlayers();

    players[0].onScreenDisplay.setTitle('Chapter 1', {
    stayDuration: 100,
    fadeInDuration: 2,
    fadeOutDuration: 4,
    subtitle: 'Trouble in Block Town',
    });
    }
    import { world, system, DimensionLocation } from '@minecraft/server';

    function countdown(targetLocation: DimensionLocation) {
    const players = world.getPlayers();

    players[0].onScreenDisplay.setTitle('Get ready!', {
    stayDuration: 220,
    fadeInDuration: 2,
    fadeOutDuration: 4,
    subtitle: '10',
    });

    let countdown = 10;

    const intervalId = system.runInterval(() => {
    countdown--;
    players[0].onScreenDisplay.updateSubtitle(countdown.toString());

    if (countdown == 0) {
    system.clearRun(intervalId);
    }
    }, 20);
    }
    索引
    isValid: boolean

    Returns true if the current reference to this screen display manager object is valid and functional.

    • 世界修改

      参数

      返回 void

      Will cause a title to show up on the player's on screen display. Will clear the title if set to empty string. You can optionally specify an additional subtitle as well as fade in, stay and fade out times.

      import { world, DimensionLocation } from '@minecraft/server';

      function setTitle(targetLocation: DimensionLocation) {
      const players = world.getPlayers();

      if (players.length > 0) {
      players[0].onScreenDisplay.setTitle('§o§6Fancy Title§r');
      }
      }
      import { world, DimensionLocation } from '@minecraft/server';

      function setTitleAndSubtitle(targetLocation: DimensionLocation) {
      const players = world.getPlayers();

      players[0].onScreenDisplay.setTitle('Chapter 1', {
      stayDuration: 100,
      fadeInDuration: 2,
      fadeOutDuration: 4,
      subtitle: 'Trouble in Block Town',
      });
      }
      import { world, system, DimensionLocation } from '@minecraft/server';

      function countdown(targetLocation: DimensionLocation) {
      const players = world.getPlayers();

      players[0].onScreenDisplay.setTitle('Get ready!', {
      stayDuration: 220,
      fadeInDuration: 2,
      fadeOutDuration: 4,
      subtitle: '10',
      });

      let countdown = 10;

      const intervalId = system.runInterval(() => {
      countdown--;
      players[0].onScreenDisplay.updateSubtitle(countdown.toString());

      if (countdown == 0) {
      system.clearRun(intervalId);
      }
      }, 20);
      }
    • 世界修改

      参数

      返回 void

      Updates the subtitle if the subtitle was previously displayed via the setTitle method.

      import { world, system, DimensionLocation } from '@minecraft/server';

      function countdown(targetLocation: DimensionLocation) {
      const players = world.getPlayers();

      players[0].onScreenDisplay.setTitle('Get ready!', {
      stayDuration: 220,
      fadeInDuration: 2,
      fadeOutDuration: 4,
      subtitle: '10',
      });

      let countdown = 10;

      const intervalId = system.runInterval(() => {
      countdown--;
      players[0].onScreenDisplay.updateSubtitle(countdown.toString());

      if (countdown == 0) {
      system.clearRun(intervalId);
      }
      }, 20);
      }