Hallo,
ich versuche gerade mit einem Tastendruck (Leertaste), eine Picturebox zu setzen. Doch das will nicht funktionieren. Ich habe auch schon in anderen Foren gesucht, doch da leider nix gefunden...
Meine Sourcecode:
Ich habe das schonmal selbst versucht, doch das klappt nicht, entweder wird er nicht angezeigt aber gesetzt, oder er wird nicht gesetzt.
Wie bekomme ich das nun zum laufen?
Danke für jede Hilfe.
MfG
Lukas
ich versuche gerade mit einem Tastendruck (Leertaste), eine Picturebox zu setzen. Doch das will nicht funktionieren. Ich habe auch schon in anderen Foren gesucht, doch da leider nix gefunden...
Meine Sourcecode:
VB.NET-Quellcode
- Public Class Game
- Private Sub Game_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim PicturePlayer As Rectangle Dim PictureBox2 As Rectangle Dim PictureBox3 As Rectangle Dim PictureBox4 As Rectangle Dim PictureBox5 As Rectangle
- If PicturePlayer.IntersectsWith(PictureBox2) Then
- End If End Sub Friend WithEvents bp As System.Windows.Forms.PictureBox
- Private Sub FormKey(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp Dim locationX As Integer Dim locationY As Integer Dim Block As PictureBox
- If e.KeyCode = Keys.Up Then PicturePlayer.Location = New Point(PicturePlayer.Location.X, PicturePlayer.Location.Y - 10) ElseIf e.KeyCode = Keys.Down Then PicturePlayer.Location = New Point(PicturePlayer.Location.X, PicturePlayer.Location.Y + 10) ElseIf e.KeyCode = Keys.Right Then PicturePlayer.Location = New Point(PicturePlayer.Location.X + 10, PicturePlayer.Location.Y) ElseIf e.KeyCode = Keys.Left Then PicturePlayer.Location = New Point(PicturePlayer.Location.X - 10, PicturePlayer.Location.Y) ElseIf e.KeyCode = Keys.Escape Then Me.Close() End If
- 'Block setzen' If e.KeyCode = Keys.Space Then locationX = PicturePlayer.Location.X + 10 locationY = PicturePlayer.Location.Y + 10 For i As Integer = 1 To 10 Dim pb As New PictureBox pb.Size = New Size(25, 25) pb.Location = New Point(i * locationX, i * locationY) Dim i20 As Integer = 20 * i pb.Image = My.Resources.Stein Me.Controls.Add(pb) Next
- MessageBox.Show(locationX, locationY) End If End SubEnd Class
Ich habe das schonmal selbst versucht, doch das klappt nicht, entweder wird er nicht angezeigt aber gesetzt, oder er wird nicht gesetzt.
Wie bekomme ich das nun zum laufen?
Danke für jede Hilfe.
MfG
Lukas