game_text
< Zh
Jump to navigation
Jump to search
![]() |
---|
CGameText |
![]() |

game_text
是一个点实体 ,可在所有的 起源 游戏,除了
求生之路2中使用。[1]
此实体用于在玩家屏幕上显示文本,并且不像env_message使用
titles.txt
文件内预置的文本[证实],此实体的文本内容可以直接在Hammer中定义。在多人游戏中,此实体通常只会向触发“Display”输出的触发者显示文本。通过勾选“All Players” Flag可以给所有玩家显示文本

titles.txt
脚本内预置的键值作为文本参数,这样无需重新编译地图即可更改文本。不像game_text
实体,其还可以使用双引号与换横符
game_text
在大部分起源游戏都支持使用多语言文本(例如#HL2_Chapter4_Title)
注意事项
Game_text
作为HUD元素的一部分渲染的,更准确的说,是/scripts/HudLayout.txt
里的HudMessage元素。
由于历史遗留问题,该实体最初是为低分辨率显示器创建的,所以默认情况下被限制为基于640x480分辨率进行缩放
这会导致分辨率高于1920x1080时出现缩放问题,文本会变得更大,并且一部分文本会被隐藏
该问题还会导致仅适用屏幕的部分区域进行文本绘制,并且长行文本或屏幕边缘附近的文本在宽屏上会被裁剪。这回影响其他适用HudMessage元素渲染的文本,比如经典的“A. I. Disabled”提示


/scripts/HudLayout.txt
并找到"HudMessage"部分,修改"wide"
和"tall"
的值(默认分别为640和480)为“f0”(显示器的完整尺寸)。这将增加文本出现的不可见VGUI屏幕的最大尺寸,使其扩展到 1920x1080 分辨率以上.[仅在2K、4K和带鱼屏上进行测试,尚不确认是否适用于所有分辨率]选项
- All Players : [1]
- 如未勾选,则仅向!activator显示文本
键值
- Name (目标名称) <target_source>[ Edit ]
- 这个名称是其他实体通过 输入/输出 或其他 关键值 (如
parentname
或target
) 来引用该实体时使用的标识符。
该名称也会显示在 Hammer 编辑器的 2D 视图和 实体报告 中。参见: 所有实体均可使用的 通用键值、输入与输出
- Message Text (message) <字符串 >
- Message to display onscreen. \n signifies a new line in the text.
错误:Hammer will automatically change backslashes to forward slashes, making \n impossible to enter.
解决方案:
- Edit the VMF with a text editor, although this will need to be reapplied after each save
- Edit the BSP entity lump with a hex editor, although this will need to be reapplied after each compile
- Use AddOutput to set the message, as outputs are not affected
[todo tested in ?]提示:
Hammer++ does not do this.
- X (0 - 1.0 = left to right) (-1 centers) (x) <字符串 >
- Horizontal position on the player's screens to draw the text. The value should be between 0 and 1, where 0 is the far left of the screen and 1 is the far right. -1 centers the text.
- Y (0 - 1.0 = top to bottom) (-1 centers) (y) <字符串 >
- Vertical position on the player's screens to draw the text. The value should be between 0 and 1, where 0 is the top of the screen and 1 is the bottom. -1 centers the text.
- Text Effect (effect) <choices>
- Text scan effect
- 0: Fade In/Out. The whole text is faded in, and then faded out.
- 1: Credits 待完善: Unknown—seems to act like Fade In/Out. Provide description.
- 2: Scan Out. The text is scanned in letter by letter, and the whole text is then faded out.
- Color1 (color) <color255 >
- The primary color used by all the text effects.
注意:The color values seem to be added to the background, so either a bright white background or black text will cause the message to be invisible.
注意:This keyvalue will default to black for entities not created in Hammer.
- Color2 (color2) <color255 >
- The scanning color for the letter being scanned if the Text Effect keyvalue is set to Scan Out—usually a different shade of Color1.
- Fade in Time (or character scan time) (fadein) <字符串 >
- The time it should take for the text to fully fade in.
- Fade Out Time (fadeout) <字符串 >
- The time it should take for the text to fade out, after the hold time has expired.
- Hold Time (holdtime) <字符串 >
- The time the text should stay onscreen, after fading in, before it begins to fade out.
注意:This value defaults to zero for entities not created in Hammer.
- Scan time (scan effect only) (fxtime) <字符串 >
- If the 'Text Effect' is set to Scan Out, this is the time it should take to scan out all the letters in the text.
- Text Channel (channel) <choices>
- You can have up to six individual game_text messages onscreen at once, stored in channels. Select which channel this text should be placed in, which will overwrite any active message already in that channel.

- Master (master) <字符串 >
- Legacy support: The name of a master entity. If the master hasn't been activated, this entity will not activate.
Inputs
- Display
- Display the message text.
注意:If the All Players flag is not set, the player must be the !activator of this input in order for the text to be shown.
- SetText <字符串 > (存在于自
以来)
- Set the text to display.

Display
input must be fired again.- SetPosX <浮点型 > (存在于自
以来)
- Set the X position of the text. (0 - 1.0 = left to right) (-1 centers)
- SetPosY <浮点型 > (存在于自
以来)
- Set the Y position of the text. (0 - 1.0 = top to bottom) (-1 centers)
- SetTextColor <color255 > (存在于自
以来)
- Set color of the front text.
- SetTextColor2 <color255 > (存在于自
以来)
- Set color of the transition text.
See also
- game_text_tf -
Displays a custom HUD message with icons on a specified team's screen.
- point_worldtext -
A similar entity that displays a custom message in the world with far more flexibility.
- training_annotation -
A similar entity that points to a specified location in the world.
- env_hudhint - Displays a custom HUD message. Commonly used to show key-binds.
- env_message - Displays a pre-defined message on the players screen.
- point_message - A similar entity that displays a small custom message at a specific position in the game world.
- Customizable triggered HUD-message - How to create a new entity that is similar to game_text but can receive the message string via a triggered input.