none
PictureBoxen mit transparenz überlappen lassen RRS feed

  • Frage

  • Ich habe in meinem Projekt (unten zu sehen)eine Picture Box mit einem Zaun als Hintergrund. Bei diesem Zaun kann man durch die Sprossen gucken. Die Hintergrundfarbe ist Transparent. Aber wenn ich eine andere Picturebox unter den Zaun schiebe(dahinter) ist sie nicht zu sehen. Nichtmal wenn ich bei der Picturebox kein Hintergrundbild und transparenten Hintergrund mache...warum?

    Quelltext:

    Public Class Spiel
        Dim direction1 As Boolean = True
        Dim direction2 As Boolean = True
        Dim direction3 As Boolean = True
        Dim letztes As String = "nothing"
        Dim last As String = Nothing
        Dim lastsize As String = Nothing
        Dim upsize As Size = New Size(77, 77)
        Dim leftsize As Size = New Size(77, 77)
        Dim downsize As Size = New Size(77, 77)
        Dim rightsize As Size = New Size(77, 77)
        Dim zeit As Integer = 0
        Dim richtung As Boolean = True
    
        Private Sub Spiel_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
            If e.KeyCode = Keys.Escape Then
                Me.WindowState = FormWindowState.Normal
                Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Sizable
            End If
    
            If e.KeyCode = Keys.Down Then
                Timer1.Enabled = True
                If Not lastsize = "down" Then
                    Me.PictureBox1.Size = downsize
                    Me.PictureBox1.BackgroundImage = My.Resources.runter3
                    Me.PictureBox1.BackColor = Color.Transparent
                    last = "down"
                    lastsize = "down"
                End If
                Dim auto As Point = New Point(PictureBox1.Location.X, PictureBox1.Location.Y + 6)
                Me.PictureBox1.Location = auto
                Timer1.Enabled = True
            End If
    
            If e.KeyCode = Keys.Up Then
                If Not lastsize = "up" Then
                    Me.PictureBox1.Size = upsize
                    Me.PictureBox1.BackgroundImage = My.Resources.hoch3
                    Me.PictureBox1.BackColor = Color.Transparent
                    last = "up"
                    lastsize = "up"
                End If
                Dim auto As Point = New Point(PictureBox1.Location.X, PictureBox1.Location.Y - 6)
                Me.PictureBox1.Location = auto
            End If
    
            If e.KeyCode = Keys.Left Then
                If Not lastsize = "left" Then
                    Me.PictureBox1.Size = leftsize
                    Me.PictureBox1.BackgroundImage = My.Resources.links3
                    Me.PictureBox1.BackColor = Color.Transparent
                    last = "left"
                    lastsize = "left"
                End If
                Dim auto As Point = New Point(PictureBox1.Location.X - 6, PictureBox1.Location.Y)
                Me.PictureBox1.Location = auto
            End If
    
            If e.KeyCode = Keys.Right Then
                If Not lastsize = "right" Then
                    Me.PictureBox1.Size = rightsize
                    Me.PictureBox1.BackgroundImage = My.Resources.rechts3
                    Me.PictureBox1.BackColor = Color.Transparent
                    last = "right"
                    lastsize = "right"
                End If
                Dim auto As Point = New Point(PictureBox1.Location.X + 6, PictureBox1.Location.Y)
                Me.PictureBox1.Location = auto
            End If
        End Sub
    
        Private Sub Spiel_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Timer1.Start()
            PictureBox5.BringToFront()
            Me.DoubleBuffered = True
        End Sub
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            Label1.Text = "Zeit: " & zeit.ToString / 50 & "s"
            zeit = zeit + 1
            If direction1 Then
                PictureBox4.Top += 14
                If (PictureBox4.Top > 800) Then
                    direction1 = False
                End If
            Else
                PictureBox4.Top -= 14
                If (PictureBox4.Top < 200) Then
                    direction1 = True
                End If
            End If
    
            If direction2 Then
                PictureBox2.Top += 14
                If (PictureBox2.Top > 800) Then
                    direction2 = False
                End If
            Else
                PictureBox2.Top -= 14
                If (PictureBox2.Top < 200) Then
                    direction2 = True
                End If
            End If
    
            If direction3 Then
                PictureBox3.Top += 14
                If (PictureBox3.Top > 800) Then
                    direction3 = False
                End If
            Else
                PictureBox3.Top -= 14
                If (PictureBox3.Top < 200) Then
                    direction3 = True
                End If
            End If
            If PictureBox1.Bounds.IntersectsWith(PictureBox2.Bounds) Or PictureBox1.Bounds.IntersectsWith(PictureBox3.Bounds) Or PictureBox1.Bounds.IntersectsWith(PictureBox4.Bounds) Then
                PictureBox1.BackgroundImage = My.Resources.splat
                Timer1.Stop()
                Me.Hide()
                won.Show()
                won.Label2.Text = "Ziel nicht erreicht"
                won.Label1.Text = "Du hast verloren"
            End If
            If PictureBox1.Bounds.IntersectsWith(Käse.Bounds) Then
                Timer1.Stop()
                Me.Hide()
                won.Show()
                won.Label2.Text = "Zeit:" & zeit / 50 & "s"
                won.Label1.Text = "Du hast Gewonnen"
            End If
        End Sub
    
    
    End Class

    Bild(runterskaliert sonst könnte ich es nicht hochladen ich hoffe es ist noch zu erkennen..):


    Montag, 27. April 2015 15:11

Antworten

Alle Antworten