跳到主要内容

在画面里放角色和展示模型

云界面的画面可以让玩家自己的角色站在一侧,像角色资讯页那样。这个角色是镜头前的真实实体,玩家穿什么它就穿什么,按住还能拖着转,别的玩家看不到。这一篇做一个有角色的画面,调好位置和镜头,加上名牌,最后把台上换成一只生物。

第 1 步:让角色站出来​

在 plugins/CloudUI/screens/ 新建 tut_portrait.yml:

portrait:
enabled: true
screen-x: 0.274
distance: 3.7
look-height: 1.02
camera:
open-ticks: 20
close-ticks: 14
elements:
backdrop:
type: image
image: main/backdrop.png
x: 0
y: 0
resolution: 0.25
fit: cover
leave:
type: button
image: main/close.png
hover: main/close_hover.png
x: 1664
y: 22
hit: [1664, 22, 236, 52]
click:
left: ['close']
leave-text:
type: text
text: '关闭'
font: text
size: 20
color: '#BECDD7'
align: center
x: 1782
y: 39

/cui reload,站在地上输入 /cui open tut_portrait。镜头会从你身上飞出去,转过来对着你自己的角色,角色站在画面偏左的位置。对着角色按住左键左右拖,它会跟着转。

portrait 一段都不写的画面也会有角色,因为 enabled 默认就是 true。不要角色的画面要明写 portrait.enabled: false。

第 2 步:调角色的位置和大小​

改 portrait: 下面的数字,每改一次 /cui reload 再打开看:

键默认说明
screen-x0.28角色身体中线在画面横向的位置,0 是最左,1 是最右
distance3.3镜头离角色几格。数字越小角色越大
look-height1.0镜头的高度(从脚底算,单位是格)。镜头是水平看过去的,调高角色就往下移
orbit18镜头绕着角色偏转的角度
face-camera22角色朝镜头转过来的角度
size1.0角色显示的大小倍率,0.2 到 5。2 是两倍大,镜头会自动拉近
follow-cursortrue能不能按住拖动旋转。false 就不能拖
drag-directionfollowfollow 是往左拖就往左转,reverse 反过来
drag-speed0.6鼠标每移动 1 像素转几度
daylighttrue画面开着时这位玩家看到的是白天,晚上打开也不会一片黑。只影响他自己

想把角色对准画面上的某个东西(名牌、脚下的转盘),把那个东西中心的 x 除以 1920,填进 screen-x。例如名牌中心在 x = 526,526 ÷ 1920 ≈ 0.274。

第 3 步:加名牌​

名牌有两种,可以一起用。

画面上的名牌​

就是普通的图片和文字,多写一行 anchor: portrait,意思是这个元素属于角色,不管玩家的视野设定是多少都贴在角色身上。在 elements: 下面加:

nameplate:
type: image
image: main/nameplate.png
x: 296
y: 902
anchor: portrait
name:
type: text
text: '{player}'
font: text
size: 28
color: '#F2F5FA'
align: center
x: 526
y: 922
anchor: portrait
level:
type: text
text: 'Lv. {level}'
font: text
size: 16
color: '#E6D3A1'
align: center
x: 526
y: 960
anchor: portrait

名牌图宽 460,放在 x = 296,中心就是 296 + 230 = 526,正好对上 screen-x: 0.274。

头顶的名牌​

在角色头顶显示名字,玩家能看到自己在别人眼里的样子。在 portrait: 下面加:

nametag:
enabled: true
source: lines
lines: ['&e{player}', '&7Lv. {level}']
y-offset: 0.3
scale: 1.0
shadow: true
键说明
sourcelines 是用下面 lines 写的内容。auto 是装了 UnlimitedNameTags 就沿用它的名牌,没装才用 lines。unt 是只用 UnlimitedNameTags 的
lines一行一个,可以用变量和 & 颜色码。不写就是一行 {player}
y-offset名牌离头顶多高,单位是格
scale大小倍率
shadow文字要不要阴影
background底色,写成 #AARRGGBB。留空就是没有底色

没写 nametag: 的画面头顶不显示名牌。

第 4 步:调镜头​

camera: 管的是镜头怎么飞、停在哪。

camera:
open-ticks: 20
close-ticks: 14
switch-ticks: 10
fov: 70

open-ticks 是打开时镜头飞过去花几 tick,close-ticks 是关闭时飞回来的时间,switch-ticks 是从别的画面切过来时镜头移动的时间。20 tick 是一秒。

不想要镜头飞行,加一行 animation: false,镜头直接就位。

固定镜头​

默认镜头是跟着角色的:玩家站在哪,角色和镜头就在哪。想让所有人打开时看到的都是同一个场景(例如大厅里搭好的展示台),用固定镜头。不用自己量坐标:

  1. 走到你想放镜头的位置,看向你想要的方向。
  2. 输入 /cui camera tut_portrait fixed。

云界面会把你眼睛的位置和方向写进画面文件,然后自动重新载入。文件里会多出这些:

camera:
mode: fixed
position:
world: world
x: 100.5
y: 66.2
z: -24.0
yaw: 180
pitch: 10

角色站的位置也可以固定。走到想让角色站的地方,面向你想让它面对的方向,输入 /cui camera tut_portrait stand,文件的 portrait: 下面会多一段 stand:。

改回来的指令:/cui camera tut_portrait follow 改回跟拍,/cui camera tut_portrait unstand 让角色回到站在玩家所在的位置。这几条都需要 cloudui.admin 权限。

固定镜头离玩家太远会失效

固定的位置和玩家不在同一个世界,或者离玩家超过服务器的视距,这次打开会自动改成跟拍。固定镜头的画面适合在那个场景附近打开。

第 5 步:台上换成一只生物或模型​

台上不一定要站玩家。portrait.show 可以放一只生物或一个模型,做宠物图鉴、坐骑展示都用它。只有打开画面的玩家看得到,一样可以拖着转,关掉画面就收走。

新建 plugins/CloudUI/screens/tut_stage.yml:

portrait:
enabled: true
show: 'entity:fox baby'
show-scale: 1.0
show-fit: 2.0
screen-x: 0.274
distance: 3.7
look-height: 1.02
camera:
open-ticks: 20
close-ticks: 14
elements:
backdrop:
type: image
image: main/backdrop.png
x: 0
y: 0
resolution: 0.25
fit: cover
nameplate:
type: image
image: main/nameplate.png
x: 296
y: 902
anchor: portrait
name:
type: text
text: '小狐狸'
font: text
size: 28
color: '#F2F5FA'
align: center
x: 526
y: 932
anchor: portrait
leave:
type: button
image: main/close.png
hover: main/close_hover.png
x: 1664
y: 22
hit: [1664, 22, 236, 52]
click:
left: ['close']
leave-text:
type: text
text: '关闭'
font: text
size: 20
color: '#BECDD7'
align: center
x: 1782
y: 39

/cui reload,/cui open tut_stage。台上站的是一只小狐狸,不是你自己。

show 有三种写法:

写法放什么
entity:生物种类一只站着不会自己走动的原版生物。后面可以加 baby 或 adult,例如 entity:fox baby
cloudmodel:模型编号CloudModel 的模型,会播它的 idle 动画。要装 CloudModel
mythicmobs:怪物编号这只 MythicMobs 怪物用 model{mid=...} 戴上的 CloudModel 模型。怪物本身不会生成,不会放技能也不会打人

另外几个键:

键默认说明
show-scale1.0大小倍率
show-fit2.0最多占几格(高和宽)。比它大的等比例缩小,比它小的不会放大。写 0 就完全不缩
player看情况写了 show 的画面默认不放玩家的角色。两个都要就写 player: true。只写 player: false 不写 show,是一个空的展示台,留给插件自己摆东西

show 里可以写变量,例如 show: '{pet_show}',打开时再带值决定放哪一只:/cui open tut_stage 玩家 pet_show=entity:wolf。插件的画面也是这样,由插件告诉云界面现在要放什么。

完整文件​

第 1 步到第 4 步合起来的 plugins/CloudUI/screens/tut_portrait.yml(镜头用跟拍,固定镜头的坐标每个服不一样,用 /cui camera 自己设):

portrait:
enabled: true
screen-x: 0.274
distance: 3.7
look-height: 1.02
orbit: 16
face-camera: 24
follow-cursor: true
daylight: true
nametag:
enabled: true
source: lines
lines: ['&e{player}', '&7Lv. {level}']
y-offset: 0.3
scale: 1.0
shadow: true
camera:
open-ticks: 20
close-ticks: 14
switch-ticks: 10
fov: 70
elements:
backdrop:
type: image
image: main/backdrop.png
x: 0
y: 0
resolution: 0.25
fit: cover
nameplate:
type: image
image: main/nameplate.png
x: 296
y: 902
anchor: portrait
motion: {x: 0, y: 20, delay: 2}
name:
type: text
text: '{player}'
font: text
size: 28
color: '#F2F5FA'
align: center
x: 526
y: 922
anchor: portrait
motion: {x: 0, y: 20, delay: 2}
level:
type: text
text: 'Lv. {level}'
font: text
size: 16
color: '#E6D3A1'
align: center
x: 526
y: 960
anchor: portrait
motion: {x: 0, y: 20, delay: 2}
heading:
type: text
text: '我的角色'
font: title
size: 44
color: '#E2EEF4'
x: 1020
y: 260
motion: {x: 160, delay: 0}
hint:
type: text
text: '按住角色左右拖动可以旋转'
font: text
size: 18
color: '#A0B6C6'
x: 1022
y: 330
motion: {x: 160, delay: 1}
leave:
type: button
image: main/close.png
hover: main/close_hover.png
x: 1664
y: 22
hit: [1664, 22, 236, 52]
click:
left: ['close']
motion: {x: 0, y: -70}
leave-text:
type: text
text: '关闭'
font: text
size: 20
color: '#BECDD7'
align: center
x: 1782
y: 39
motion: {x: 0, y: -70}

tut_stage.yml 的完整内容就是第 5 步那一份。

常见问题​

角色被背景整个盖住,后台提示背景「几乎不透明」​

铺满画面的背景图(fit: cover)只有透明或半透明的地方才看得到后面的角色。背景在角色站的那一块是实心的,角色就被盖住了,重新载入时后台会提示是哪个画面、哪张图、哪个 screen-x。把背景图在那一块做成透明或半透明(不透明度 60% 以下)就好。自带的 main/backdrop.png 左半边是半透明的,所以用它的时候 screen-x 不要超过 0.55 左右。

打开时提示「请先落地再开启选单」​

默认要站在地上才能开选单,在半空打开的话角色会卡在空中直到关闭。水里、梯子上、飞行中不受限制,有 cloudui.bypass.ground 权限的玩家也不受限制;整个关掉是 config.yml 的 menu.require-ground: false。另外骑乘、滑翔、睡觉、旁观模式下选单打不开。

后台提示 portrait.show 某某​

show 写的东西放不出来,台上会是空的。几种原因后台都会写明:is not a mob type 是 entity: 后面的生物种类写错,CloudModel is not installed 是没装 CloudModel,CloudModel has no model 是模型编号不对,write cloudmodel:<model>, mythicmobs:<mob> or entity:<type> 是开头的种类写错了。

重新载入时提示 camera.mode fixed needs camera.position​

写了 mode: fixed 却没有 position。用 /cui camera 画面名 fixed 设一次,或者把 mode 改回 follow。

相关页面​

0:000:00