Ich habe vor, ein kleines Game zu machen. Leider erstellt das Script beim Nachladen der Muition die Icons nicht mehr.
Hoffe es kann mir jemand helfen :=)
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <ButtonConstants.au3>
#include<misc.au3>
Global $max_ammo = 5, $current_ammo=5,$timerinit=50, $timerinit2=50,$nullammo="0",$null1=0,$null2=0,$null3=0,$null4=0,$null5=0
lvl_1()
Func lvl_1(); ==> lvl_1
$level="1"
#Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\Sebastian\Desktop\autoit\spiel\lvl_1.kxf
$lvl_1 = GUICreate("Level_1", 838, 602, 200, 137, $WS_POPUP)
$Pic1 = GUICtrlCreatePic("background.jpg", 0, 0, 836, 508, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetCursor(-1, 3)
GUICtrlSetState(-1, $GUI_DISABLE)
$Pic2 = GUICtrlCreatePic("menu.jpg", 0, 508, 836, 92, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE)
$btn = GUICtrlCreateIcon("exit.ico", -1, 745, 508, 92, 92) ; --> die letzte 0, damit kein Klick-Ereignis ausgelöst wird (Click-Through)
$Label1 = GUICtrlCreateLabel("Munition:", 16, 512, 90, 28)
GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1,0x5e2d64)
$Label2 = GUICtrlCreateLabel("Leben:", 16, 536, 69, 28)
GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1,0x5e2d64)
$Label3 = GUICtrlCreateLabel("Level: " & $level, 16, 568, 200, 28)
GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1,0x5e2d64)
global $leben1 = GUICtrlCreateIcon("leben.ico", -1, 144, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $leben2 = GUICtrlCreateIcon("leben.ico", -1, 112, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $leben3 = GUICtrlCreateIcon("leben.ico", -1, 176, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $leben4 = GUICtrlCreateIcon("leben.ico", -1, 208, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $leben5 = GUICtrlCreateIcon("leben.ico", -1, 240, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $ammo1 = GUICtrlCreateIcon("munition.ico", -1, 112, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $ammo2 = GUICtrlCreateIcon("munition.ico", -1, 144, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $ammo3 = GUICtrlCreateIcon("munition.ico", -1, 176, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $ammo4 = GUICtrlCreateIcon("munition.ico", -1, 208, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $ammo5 = GUICtrlCreateIcon("munition.ico", -1, 240, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_GuiRoundCorners($lvl_1, 0, 0, 50, 50)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btn
main_gui()
EndSwitch
check_ammo()
WEnd
EndFunc ;==>lvl_1
func main_gui() ;==> Hauptfenster
exit(1)
endfunc ;==> Hauptfenster
func check_ammo()
if _IsPressed('01') Then
$timerdiff= TimerDiff($timerinit)
if $timerdiff >= 100 Then
if $current_ammo = 5 then
GUICtrlDelete($ammo5)
$null5=1
endif
if $current_ammo = 4 then
GUICtrlDelete($ammo4)
$nullammo4=1
endif
if $current_ammo = 3 then
GUICtrlDelete($ammo3)
$nullammo3=1
endif
if $current_ammo = 2 then
GUICtrlDelete($ammo2)
$nullammo2=1
endif
if $current_ammo = 1 then
GUICtrlDelete($ammo1)
$nullammo1=1
endif
if $current_ammo = 0 Then
global $nullammo="1"
global $Label4 = GUICtrlCreateLabel("!!!!Keine Munition!!!!", 280, 184, 297, 42)
GUICtrlSetFont(-1, 20, 800, 0, "Arial Black")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1,0xe2b75b)
;Hier sieht man dann nur den letze Hülse, die wird aber öffters erstellt, da man nach 5 mal drücken nicht verschwindet.
;eigentlich sollen hier wieder alle Hülsen so schön in der Reihe stehen, wie am Anfang. Und jedes nur 1mal.
global $ammo1 = GUICtrlCreateIcon("munition.ico", -1, 112, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $ammo2 = GUICtrlCreateIcon("munition.ico", -1, 144, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $ammo3 = GUICtrlCreateIcon("munition.ico", -1, 176, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $ammo4 = GUICtrlCreateIcon("munition.ico", -1, 208, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
global $ammo5 = GUICtrlCreateIcon("munition.ico", -1, 240, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
endif
$current_ammo=$current_ammo -1
endif
$timerinit=TimerInit()
endif
if _IsPressed('02') Then ; Hier brauch ich Hilfe: er erstellt die Icons nicht wieder her, theoretisch geht alles, aber die werden nicht mehr angezeigt.
$timerdiff2=TimerDiff($timerinit2)
if $timerdiff2 >= 500 then
if $nullammo ="1" then
GUICtrlDelete($label4)
$nullammo="0"
endif
if $null5=1 Then
global $ammo5 = GUICtrlCreateIcon("munition.ico", -1, 240, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$current_ammo=5
EndIf
if $null4=1 Then
global $ammo4 = GUICtrlCreateIcon("munition.ico", -1, 208, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$current_ammo=4
EndIf
if $null3=1 Then
global $ammo3 = GUICtrlCreateIcon("munition.ico", -1, 176, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$current_ammo=3
EndIf
if $null2=1 Then
global $ammo2 = GUICtrlCreateIcon("munition.ico", -1, 144, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$current_ammo=2
EndIf
if $null1=1 Then
global $ammo1 = GUICtrlCreateIcon("munition.ico", -1, 112, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$current_ammo=1
EndIf
endif
$timerinit2 =TimerInit()
endif
endfunc
;#######Zusatzfunktion####################
Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
Dim $pos, $ret, $ret2
$pos = WinGetPos($h_win)
$ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
If $ret[0] Then
$ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
If $ret2[0] Then
Return 1
Else
Return 0
EndIf
Else
Return 0
EndIf
EndFunc ;==>_GuiRoundCorners
MFG Sebastian