跳转到正文
iPlugin

制作通知弹窗

已登记资产 → 局部 Layout → Popup 显示组 → 触发

Popup 是按需触发的临时画面。先准备它的图片和字体,再创建 Layout,最后配置显示位置、时间与队列。

三条通知同时显示的外观参考

资产前提

本页复用两项已经存在的资产,不重复复制:

资产ID / 地址来源
字体tutorial_font添加字体
面板 PNGxerr_ui / panel / noticeXerr 自带图片组

自带面板文件是 core/assets/image/xerr_ui/panel/textures/notice.png,对应登记在同组 config.yml。如果删除了默认资产,请恢复这两个文件或先登记自己的面板。

文件结构

tutorial_popup.yml
tutorial.yml

创建局部 Layout

plugins/Xerr/core/layout/tutorial_popup.yml
defaults:
  font: tutorial_font
  image:
    namespace: xerr_ui
    basename: panel

tutorial_popup:
  panel:
    y: 12
    image:
      id: notice
  title:
    layer: 10
    x: 52
    y: 9
    value: "&f{{ get title }}"
  message:
    layer: 10
    x: 52
    y: -7
    value: "&7{{ get message }}"

Popup Layout 内不写 anchor,整块画面由外层显示组定位。它不用再加入常驻 HUD。

创建显示组

plugins/Xerr/core/display/popups/tutorial.yml
tutorial_notifications:
  anchor:
    x: 100
    y: 0
  slots:
    - x: -236
      y: -14
    - x: -236
      y: -68
    - x: -236
      y: -122
  pending-limit: 256
  reflow:
    duration: 6
    easing: ease-out
  popups:
    tutorial_notice:
      layout: tutorial_popup
      duration: 80
      refresh: 5
      variables:
        title: "通知"
        message: "欢迎来到服务器"
      animation:
        enter:
          duration: 8
          easing: ease-out
          from:
            x: 236
        exit:
          duration: 6
          easing: ease-in
          to:
            x: 236

slots 有三个位置,就能同时显示三条;更多实例等待空位。duration 是入场完成后的停留时间,80 tick 通常约 4 秒。

打包后触发

/xerr pack
/xerr popup show tutorial_notice

客户端先加载新包,再执行第二条命令。连续触发四次,可看到前三条显示、第四条排队。

给指定玩家:

/xerr popup show tutorial_notice Steve

成功时不会发送聊天回执;错误和列表仍会输出。