For\next icons variablen

  • Hallo Leute,
    es geht darum ich möchte ein spiel konstruieren und dabei gibt es ein Problem:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    HotKeySet("{f}", "_Fire")
    HotKeySet("{Space}", "_Reload")
    Global $ishot = 10
    Global $icon[11]

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Schuss Funktion ", 498, 242, 269, 188)
    $Icon[10] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 168, 200, 32, 32)
    $Icon[9] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 200, 200, 32, 32)
    $Icon[8] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 232, 200, 32, 32)
    $Icon[7] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 264, 200, 32, 32)
    $Icon[6] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 296, 200, 32, 32)
    $Icon[5] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 328, 200, 32, 32)
    $Icon[4] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 360, 200, 32, 32)
    $Icon[3] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 392, 200, 32, 32)
    $Icon[2] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 424, 200, 32, 32)
    $Icon[1] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 456, 200, 32, 32)
    $Label1 = GUICtrlCreateLabel("10", 136, 40, 36, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Fire()
    GUICtrlDelete($icon[$ishot])
    $ishot = $ishot -1
    GUICtrlSetData($label1, $ishot)
    If $ishot < 1 Then
    MsgBox(0, "Moorhuhn", "Sie haben keine muntion mehr, laden sie nach")
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Reload()
    $iFiredshot = $ishot
    $iShot = 10
    GUICtrlSetData($label1, $ishot)
    EndFunc

    [/autoit]


    das is bis jetzt nur die Schuss FUnktion aber schon da gibt es ein Problem.. Ich kriege es einfach nich hin das wenn man reloadet alle die Icons die fehlen wieder herstellt ich hatte mir gedacht das diese Problem vlt.. mit For und next zu lösen ist konnte es aber nicht umsetzen. Manche würden sich vlt denken erstellt doch einfach jedes mal 10 neue Icons.. wer das meint sollte das mal testen...Wer sich jetzt nichts unter dem Schusssystem vor stehlen kann ..Es ist sowas wie z.B bei Moorhuhn

    Mit freundlichen Grüßen CF*Gaming

  • Anstatt die icons zu löschen und neuzuerstellen würde ich diese unsichtbar und sichtbar machen.

    [autoit]


    GUICtrlDelete($icon[$ishot])
    ;durch das ersetzen:
    GUICtrlSetState($icon[$ishot],$GUI_HIDE)

    [/autoit][autoit][/autoit][autoit]

    ; und in deiner reload funktion dann in einer schleife alle 10 icons wieder sichtbar machen:

    [/autoit][autoit][/autoit][autoit]

    $ishot = 0
    while $ishot <= 9
    $ishot = $ishot + 1
    GUICtrlSetState($icon[$ishot],$GUI_SHOW)
    Wend

    [/autoit]

    Sorry ist nicht getestet, sollte aber funktionieren.

  • ah oaky ..Funktioniert perfect:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    HotKeySet("{f}", "_Fire")
    HotKeySet("{Space}", "_Reload")
    Global $ishot = 10
    Global $icon[11]

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Schuss Funktion ", 498, 242, 269, 188)
    $Icon[10] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 168, 200, 32, 32)
    $Icon[9] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 200, 200, 32, 32)
    $Icon[8] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 232, 200, 32, 32)
    $Icon[7] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 264, 200, 32, 32)
    $Icon[6] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 296, 200, 32, 32)
    $Icon[5] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 328, 200, 32, 32)
    $Icon[4] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 360, 200, 32, 32)
    $Icon[3] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 392, 200, 32, 32)
    $Icon[2] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 424, 200, 32, 32)
    $Icon[1] = GUICtrlCreateIcon("E:\Icon\lock.ico", -1, 456, 200, 32, 32)
    $Label1 = GUICtrlCreateLabel("10", 136, 40, 36, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Fire()
    GUICtrlSetState($icon[$ishot],$GUI_HIDE)
    $ishot = $ishot -1
    GUICtrlSetData($label1, $ishot)
    If $ishot < 1 Then
    MsgBox(0, "Moorhuhn", "Sie haben keine muntion mehr, laden sie nach")
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Reload()
    If $ishot = 10 Then
    MsgBox(0, "", "")
    Else
    $iFiredshot = $ishot
    $iShot = 10
    GUICtrlSetData($label1, $ishot)
    ;~ MsgBox(0, "", $iFiredshot)
    For $i = 0 to 10 Step +1
    GUICtrlSetState($icon[$i],$GUI_SHOW)
    Next
    EndIf
    EndFunc

    [/autoit]
  • Hm, nunja ....

    Spoiler anzeigen
    [autoit]


    $Pfad = "E:\Icon\lock.ico"

    [/autoit] [autoit][/autoit] [autoit]

    $Form2 = GUICreate("Schuss Funktion ", 498, 242, 269, 188)
    $Icon[10] = GUICtrlCreateIcon($Pfad , -1, 168, 200, 32, 32)
    $Icon[9] = GUICtrlCreateIcon($Pfad , -1, 200, 200, 32, 32)
    $Icon[8] = GUICtrlCreateIcon($Pfad , -1, 232, 200, 32, 32)
    $Icon[7] = GUICtrlCreateIcon($Pfad , -1, 264, 200, 32, 32)
    $Icon[6] = GUICtrlCreateIcon($Pfad , -1, 296, 200, 32, 32)
    $Icon[5] = GUICtrlCreateIcon($Pfad , -1, 328, 200, 32, 32)
    $Icon[4] = GUICtrlCreateIcon($Pfad , -1, 360, 200, 32, 32)
    $Icon[3] = GUICtrlCreateIcon($Pfad , -1, 392, 200, 32, 32)
    $Icon[2] = GUICtrlCreateIcon($Pfad , -1, 424, 200, 32, 32)
    $Icon[1] = GUICtrlCreateIcon($Pfad , -1, 456, 200, 32, 32)
    $Label1 = GUICtrlCreateLabel("10", 136, 40, 36, 17)
    GUISetState(@SW_SHOW)

    [/autoit]