私は自分の形に描いたこれらの3つの画像を持っています。
GraphicsBuffer.DrawImage(ButtonEasy, New Rectangle(25, 330, 100, 50), 0, 0, 100, 50, GraphicsUnit.Pixel, ImageAttributes)
GraphicsBuffer.DrawImage(ButtonMedium, New Rectangle(150, 330, 100, 50), 0, 0, 100, 50, GraphicsUnit.Pixel, ImageAttributes)
GraphicsBuffer.DrawImage(ButtonHard, New Rectangle(275, 330, 100, 50), 0, 0, 100, 50, GraphicsUnit.Pixel, ImageAttributes)
ただし、クリックされたときのブール式を作成して、選択したゲームモードをロードするイベントをトリガーできるようにします。
リソースコードを使用してこれを実行しますか、それともこれを実行する簡単な方法がありますか。私の考えはそれが悪く、構文的に正しくないようです。
編集:私はこれに到達しました:
Private Sub ButtonEasy_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs) _
Handles ButtonEasy.MouseClick
Dim buttonEasyRect = New Rectangle(25, 330, 100, 50)
If buttonEasyRect.Contains(e.Location) Then
End If
End Sub
しかし、これからどこに行くべきか本当にわかりません。どうやら「ButtonEasy.Mouseclick」ハンドルは「WithEventsvariableundefined」というエラーをスローします。ここからどこへ行くのかわからない。
前もって感謝します!
Edit2:LarsTechの助けを借りて、列挙型を取得しました。これは次のとおりです。
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseDown
Dim level As Difficulty = Difficulty.None
If e.Button = MouseButtons.Left Then
End If
If New Rectangle(25, 330, 100, 50).Contains(e.Location) Then
level = Difficulty.Easy
ElseIf New Rectangle(150, 330, 100, 50).Contains(e.Location) Then
level = Difficulty.Medium
ElseIf New Rectangle(275, 330, 100, 50).Contains(e.Location) Then
level = Difficulty.Hard
End If
If level = Difficulty.Easy Then
GameMode = 1
ElseIf level = Difficulty.Medium Then
GameMode = 2
ElseIf level = Difficulty.Hard Then
GameMode = 3
End If
End Sub
ループでこれを呼び出すにはどうすればよいですか?現在、Asynchkeypressがタイムスケールを300に設定してゲームを開始するのをループで待機しています。