行 30: |
行 30: |
| | up | | | up |
| | up | | | up |
− | | <samp> 无</samp> | + | | <samp>None</samp> |
| |- | | |- |
| | up | | | up |
| | down | | | down |
− | | <samp> 按下</samp> | + | | <samp>Pressed</samp> |
| |- | | |- |
| | down | | | down |
| | down | | | down |
− | | <samp> 按住</samp> | + | | <samp>Held</samp> |
| |- | | |- |
| | down | | | down |
| | up | | | up |
− | | <samp> 松开</samp> | + | | <samp>Released</samp> |
| |} | | |} |
| </dd> | | </dd> |
行 89: |
行 89: |
| 副作用: | | 副作用: |
| <ul> | | <ul> |
− | <li>The [[Modding:Modder Guide/APIs/Events#Input.ButtonReleased|<samp>ButtonReleased</samp> event]] will be raised on the next tick for the suppressed input.</li> | + | <li>[[Modding:Modder Guide/APIs/Events#Input.ButtonReleased|<samp>ButtonReleased</samp> 事件]] 会在输入被抑制后的下一个 tick 触发。</li> |
− | <li>Methods like <samp>helper.Input.IsDown(button)</samp> and <samp>helper.Input.GetState(button)</samp> will show the button as released for the duration of the suppression, even if it's physically still pressed. You can use <samp>helper.Input.IsSuppressed(button)</samp> to check if that's the case (it will only be true until the button is physically released): | + | <li> 在按键被抑制期间,类似 <samp>helper.Input.IsDown(button)</samp> 和 <samp>helper.Input.GetState(button)</samp> 的方法会表明按键的状态是 released ,即使该按键在现实中处于被按下的状态。你可以使用 <samp>helper.Input.IsSuppressed(button)</samp> 来检查按键是否处于这种情况(它会一直返回 true 直到按键在现实中被松开): |
| <syntaxhighlight lang="c#"> | | <syntaxhighlight lang="c#"> |
| bool isPhysicallyDown = helper.Input.IsDown(button) || helper.Input.IsSuppressed(button); | | bool isPhysicallyDown = helper.Input.IsDown(button) || helper.Input.IsSuppressed(button); |
行 96: |
行 96: |
| </ul> | | </ul> |
| | | |
− | ==Data structures== | + | == 数据结构== |
| ===SButton=== | | ===SButton=== |
− | SMAPI's <samp>SButton</samp> is a constant which includes every [https://docs.microsoft.com/en-us/previous-versions/windows/xna/bb975202(v%3dxnagamestudio.40) controller], [https://docs.microsoft.com/en-us/previous-versions/windows/xna/bb197781(v%3dxnagamestudio.40) keyboard], and [https://docs.microsoft.com/en-us/previous-versions/windows/xna/bb198097(v%3dxnagamestudio.40) mouse] button. SMAPI events use this to let you handle button presses without needing separate code for each. See [[Modding:Player Guide/Key Bindings]] for a list of values. | + | SMAPI 的 <samp>SButton</samp> 是一个涵盖了每种[https://docs.microsoft.com/en-us/previous-versions/windows/xna/bb975202(v%3dxnagamestudio.40) 控制器], [https://docs.microsoft.com/en-us/previous-versions/windows/xna/bb197781(v%3dxnagamestudio.40) 键盘] 和[https://docs.microsoft.com/en-us/previous-versions/windows/xna/bb198097(v%3dxnagamestudio.40) 鼠标] 的按键的常量。SMAPI 事件使用此常量,这允许你处理按键按下时不需要区分每种按键的代码。阅读 [[Modding:Player Guide/Key Bindings]] 来获取值列表。 |
| | | |
− | SMAPI provides extensions to convert any of the other constants to <samp>SButton</samp>: | + | SMAPI 提供了把任意其他常量转换为 <samp>SButton</samp> 的扩展: |
| <syntaxhighlight lang="c#"> | | <syntaxhighlight lang="c#"> |
| SButton key = Keys.A.ToSButton(); // SButton.A | | SButton key = Keys.A.ToSButton(); // SButton.A |