实验性
实验性
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
实验性
可选
hudElements: HudElement[]无法在只读模式下调用此函数,详见 WorldBeforeEvents。
实验性
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
实验性
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
实验性
New value for the action bar text.
Set the action bar text - a piece of text that displays beneath the title and above the hot-bar.
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
实验性
Whether to set the HUD element to invisible, or to reset it back to its default.
可选
hudElements: HudElement[]Optional list of HUD elements to configure visibility for.
Sets visibility of a particular element of the heads up display (HUD).
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
实验性
可选
options: TitleDisplayOptionsWill 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.
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
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);
}
实验性
Updates the subtitle if the subtitle was previously displayed via the setTitle method.
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
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);
}
Contains information about user interface elements that are showing up on the screen.
示例: setTitle.ts
示例: setTitleAndSubtitle.ts
示例: countdown.ts