更改

添加2,040字节 、 2021年6月10日 (四) 06:06
无编辑摘要
第146行: 第146行:  
  // 调用:
 
  // 调用:
 
  Game1.getLocationFromName("Town").addCharacter(npc);
 
  Game1.getLocationFromName("Town").addCharacter(npc);
 +
</syntaxhighlight>
 +
 +
==用户界面 (UI)==
 +
用户界面(User-interface、UI) 是指一系列有关界面元素(如按钮、列表框、下拉框等等)以及它们组合起来呈现的画面(如菜单、HUD等等)。
 +
 +
//TODO:欢迎补充UI方面的内容。
 +
 +
===HUD消息===
 +
HUD消息是指你屏幕左下角时常弹出来的消息框。以下是它的构造函数(不包括一部分无关的):
 +
<syntaxhighlight lang='c#'>
 +
public HUDMessage(string message);
 +
public HUDMessage(string message, int whatType);
 +
public HUDMessage(string type, int number, bool add, Color color, Item messageSubject = null);
 +
public HUDMessage(string message, string leaveMeNull)
 +
public HUDMessage(string message, Color color, float timeLeft, bool fadeIn)
 +
</syntaxhighlight>
 +
 +
[[File:HUDMessage-Types-InGame.png|200px|thumb|right|样式一览]]
 +
 +
可选的'''样式'''(type):
 +
# 成就 <code>HUDMessage.achievement_type</code>
 +
# 新任务 <code>HUDMessage.newQuest_type</code>
 +
# 错误 <code>HUDMessage.error_type</code>
 +
# 体力值 <code>HUDMessage.stamina_type</code>
 +
# 生命值 <code>HUDMessage.health_type</code>
 +
 +
'''颜色'''(color):
 +
第1、2个构造器并没有给出表示颜色的参数,此时颜色默认为<code>Color.OrangeRed</code>。
 +
若使用第4个构造器,颜色则与游戏内文字颜色一样。
 +
 +
特别:
 +
* ''public HUDMessage(string type, int number, bool add, Color color, Item messageSubject = null);'' 支持消息内容扩展。常用于金钱相关。
 +
* ''public HUDMessage(string message, string leaveMeNull);'' 左侧没有图标框。
 +
* ''public HUDMessage(string message, Color color, float timeLeft, bool fadeIn);'' 文字渐入效果。
 +
 +
示例1:
 +
 弹出一个带有[[File:Error-image-ingame.png]]的消息框。
 +
<syntaxhighlight lang='c#'>
 +
Game1.addHUDMessage(new HUDMessage("MESSAGE", 3));
 +
</syntaxhighlight>
 +
示例2:
 +
弹出一个不带纯文字的消息框。
 +
<syntaxhighlight lang='c#'>
 +
Game1.addHUDMessage(new HUDMessage("MESSAGE", ""));  // second parameter is the 'leaveMeNull' parameter
 
</syntaxhighlight>
 
</syntaxhighlight>
    
[[en:Modding:Common tasks]]
 
[[en:Modding:Common tasks]]
 
[[ru:Модификации:Основные возможности]]
 
[[ru:Модификации:Основные возможности]]
50

个编辑