public override void TouchDown(LTouch touch) { if (desktop != null) { LComponent[] cs = desktop.GetContentPane().GetComponents(); for (int i = 0; i < cs.Length; i++) { if (cs[i] is LButton) { LButton btn = ((LButton)cs[i]); if (btn != null && btn.IsVisible()) { if (btn.Intersects(touch.X(), touch.Y())) { btn.DoClick(); } } } else if (cs[i] is LPaper) { LPaper paper = ((LPaper)cs[i]); if (paper != null && paper.IsVisible()) { if (paper.Intersects(touch.X(), touch.Y())) { paper.DoClick(); } } } } } Click(); }
public override void OnLoading() { roleName = new LPaper("assets/name0.png", 25, 25); LeftOn(roleName); roleName.SetLocation(5, 15); Add(roleName); }
public override void OnLoad() { // 设置指定背景图 // SetBackground("assets/back2.png"); // 变更背景 SetBackground("assets/back1.png"); // 创建一个开始按钮,按照宽191,高57分解按钮图,并设定其Click事件 start = new LButton("assets/title_start.png", 191, 57); // 设定按钮位置为x=2,y=5 start.SetLocation(2, 5); // 设定此按钮不可用 start.SetEnabled(false); start.Tag = this; start.Click = new StartClick(); // 添加按钮 Add(start); // 创建一个记录读取按钮,按照宽160,高56分解按钮图 LButton btn2 = new LButton("assets/title_load.png", 160, 56); // 设定按钮位置为x=2,y=start位置类推 btn2.SetLocation(2, start.GetY() + start.GetHeight() + 20); // 设定此按钮不可用 btn2.SetEnabled(false); // 添加按钮 Add(btn2); // 创建一个环境设置按钮,按照宽215,高57分解按钮图 LButton btn3 = new LButton("assets/title_option.png", 215, 57); // 设定按钮位置为x=2,y=btn2位置类推 btn3.SetLocation(2, btn2.GetY() + btn2.GetHeight() + 20); // 设定此按钮不可用 btn3.SetEnabled(false); // 添加按钮 Add(btn3); // 创建一个退出按钮,按照宽142,高57分解按钮图,并设定其Click事件 end = new LButton("assets/title_end.png", 142, 57); // 设定按钮位置为x=2,y=btn3位置类推 end.SetLocation(2, btn3.GetY() + btn3.GetHeight() + 20); // 设定此按钮不可用 end.SetEnabled(false); // 添加按钮 Add(end); // 增加一个标题 title = new LPaper("assets/title.png", -200, 0); // 添加标题 Add(title); }
public override void Alter(LTimerContext t) { if (IsWait()) { return; } if (timer1 == null) { timer1 = new LTimer(50); } if (title != null && timer1.Action(t.GetTimeSinceLastUpdate())) { if (title.GetY() > 50) { title.Move_up(8); title.ValidatePosition(); } else if (title.GetAlpha() > 0.2f) { title.SetAlpha(title.GetAlpha() - 0.1f); } else { title.SetVisible(false); Remove(title); title = null; } return; } else if (over != null && timer1.Action(t.GetTimeSinceLastUpdate()) && !overFlag) { if (over.GetY() < (GetHeight() - over.GetHeight()) / 2) { over.Move_down(8); over.ValidatePosition(); } else if (over.GetAlpha() < 1.0f) { over.SetAlpha(over.GetAlpha() + 0.1f); } else { CenterOn(over); overFlag = true; } return; } if (!wingame) { if (timer == null) { timer = new LTimer(100); } if (timer.Action(t.GetTimeSinceLastUpdate())) { if (progress != null) { progress.SetUpdate(progress.GetValue() - (stageNo * 30)); if (progress.GetValue() <= 100 && !failgame) { failgame = true; GetSprites().SetVisible(false); over = new LPaper(GetImage(16), 0, 0); over.Click = new OverClick(); over.SetAlpha(0.1f); CenterOn(over); over.SetY(0); Add(over); } } } } else { wingame = false; RemoveAll(); Stage(stageNo + 1); } }