更改

跳到导航 跳到搜索
第120行: 第120行:     
        // 向控制台输出按下了什么按钮
 
        // 向控制台输出按下了什么按钮
        this.Monitor.Log($"{Game1.player.Name} pressed {e.Button}.", LogLevel.Debug);
+
        this.Monitor.Log($"{Game1.player.Name} 按下了 {e.Button}.", LogLevel.Debug);
 
      }
 
      }
 
    }
 
    }
第127行: 第127行:  
</ol>
 
</ol>
   −
Here's a breakdown of what that code is doing:
+
以下是该代码的功能细分:
   −
# <code>using X;</code> (see [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive using directive]) makes classes in that namespace available in your code.
+
# <code>using X;</code> ( 参阅 [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive using directive]) 使该命名空间中的类在你的代码中可用
# <code>namespace YourProjectName</code> (see [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/namespace namespace keyword]) defines the scope for your mod code. Don't worry about this when you're starting out, Visual Studio or MonoDevelop will add it automatically when you add a file.
+
# <code>namespace YourProjectName</code> ( 参阅 [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/namespace namespace keyword]) 定义代码的范围,入门时不必担心,因为在新建类文件时 Visual Studio MonoDevelop 会自动添加它
# <code>public class ModEntry : Mod</code> (see [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/class class keyword]) creates your mod's main class, and subclasses SMAPI's <tt>Mod</tt> class. SMAPI will detect your <tt>Mod</tt> subclass automatically, and <tt>Mod</tt> gives you access to SMAPI's APIs.
+
# <code>public class ModEntry : Mod</code> ( 参阅 [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/class class keyword]) 创建你的模组的主类文件,并继承 SMAPI <tt>Mod</tt> 类。SMAPI 将自动检测你的 <tt>Mod</tt> 子类,而 <tt>Mod</tt> 使你可访问 SMAPI 的接口
# <code>public override void Entry(IModHelper helper)</code> is the method SMAPI will call when your mod is loaded into the game. The <code>helper</code> provides convenient access to many of SMAPI's APIs.
+
# <code>public override void Entry(IModHelper helper)</code> 是将模组加载到游戏中时 SMAPI 将调用的方法。这里的 <code>helper</code> 对象提供了对许多 SMAPI 接口的便捷访问
# <code>helper.Events.Input.ButtonPressed += this.OnButtonPressed;</code> adds an 'event handler' (i.e. a method to call) when the button-pressed event happens. In other words, when a button is pressed (the <tt>helper.Events.Input.ButtonPressed</tt> event), SMAPI will call your <tt>this.OnButtonPressed</tt> method. See [[Modding:Modder Guide/APIs/Events|events in the SMAPI reference]] for more info.
+
# <code>helper.Events.Input.ButtonPressed += this.OnButtonPressed;</code> 添加了一个 ' 事件绑定' (i.e. a method to call) 到当按下按钮的事件发生时. 换句话说,当一个按钮被按下 ( 也就是 <tt>helper.Events.Input.ButtonPressed</tt> 事件触发了), SMAPI 会调用你的 <tt>this.OnButtonPressed</tt> 方法。参阅 [[ 模组:Modder Guide/APIs/Events|SMAPI 中的事件]] 获取更多信息
    
===Add your manifest===
 
===Add your manifest===
203

个编辑

导航菜单