Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ClickableWidget.cs
浏览该文件的文档.
1namespace Game {
2 public class ClickableWidget : Widget {
3 public string SoundName { get; set; }
4
5 public bool IsPressed { get; set; }
6
7 public bool IsClicked { get; set; }
8
9 public bool IsTapped { get; set; }
10
11 public bool IsChecked { get; set; }
12
13 public bool IsAutoCheckingEnabled { get; set; }
14
15 public override void UpdateCeases() {
16 base.UpdateCeases();
17 IsPressed = false;
18 IsClicked = false;
19 IsTapped = false;
20 }
21
22 public override void Update() {
23 WidgetInput input = Input;
24 IsPressed = false;
25 IsTapped = false;
26 IsClicked = false;
27 if (input.Press.HasValue
28 && HitTestGlobal(input.Press.Value) == this) {
29 IsPressed = true;
30 }
31 if (input.Tap.HasValue
32 && HitTestGlobal(input.Tap.Value) == this) {
33 IsTapped = true;
34 }
35 if (input.Click.HasValue
36 && HitTestGlobal(input.Click.Value.Start) == this
37 && HitTestGlobal(input.Click.Value.End) == this) {
38 IsClicked = true;
41 }
42 if (!string.IsNullOrEmpty(SoundName)) {
43 AudioManager.PlaySound(SoundName, 1f, 0f, 0f);
44 }
45 }
46 }
47 }
48}
static void PlaySound(string name, float volume, float pitch, float pan)
virtual Widget HitTestGlobal(Vector2 point, Func< Widget, bool > predicate=null)
WidgetInput Input