mblunk Posted January 13, 2008 Posted January 13, 2008 (edited) #include <GUIConstants.au3> $x = 0 $y = 0 $game = GUICreate("Game", 300, 300) $pic = GUICtrlCreateGraphic(150, 150, 5, 5) GUICtrlSetColor($pic, 0xff00000) GUICtrlSetBkColor($pic, 0xff0000) GUICtrlSetGraphic($pic, $GUI_GR_RECT, $x, $y, 5, 5) $left = GUICtrlCreateButton("Left", 1, 1, 40, 20) $right = GUICtrlCreateButton("Right", 42, 1, 40, 20) $up = GUICtrlCreateButton("Up", 83, 1, 40, 20) $down = GUICtrlCreateButton("Down", 124, 1, 40, 20) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $left $x -= 1 Case $right $x += 1 Case $up $y += 1 Case $down $y -= 1 EndSwitch GUICtrlSetGraphic($pic, $GUI_GR_RECT, $x, $y, 5, 5) ToolTip("X = " & $x & @LF & "Y = " & $y) WEnd I can tell from the tooltip that the variables are updating, just not the graphic. What am I doing wrong? Edited January 13, 2008 by mblunk
Matteo Posted January 13, 2008 Posted January 13, 2008 Try this: #include <GUIConstants.au3> $x = 0 $y = 0 $game = GUICreate("Game", 300, 300) $pic = GUICtrlCreateGraphic(150, 150, 5, 5) GUICtrlSetColor($pic, 0xff00000) GUICtrlSetBkColor($pic, 0xff0000) GUICtrlSetGraphic($pic, $GUI_GR_RECT, $x, $y, 5, 5) $left = GUICtrlCreateButton("Left", 1, 1, 40, 20) $right = GUICtrlCreateButton("Right", 42, 1, 40, 20) $up = GUICtrlCreateButton("Up", 83, 1, 40, 20) $down = GUICtrlCreateButton("Down", 124, 1, 40, 20) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $left $x -= 1 Case $right $x += 1 Case $up $y += 1 Case $down $y -= 1 EndSwitch GUICtrlSetPos($pic,150+$x,150-$y) ToolTip("X = " & $x & @LF & "Y = " & $y) WEnd ,.-~*´¨¯¨`*·~-.¸-(_[M]¦¦[A]¦¦[T]¦¦[T]¦ ¦[E]¦¦[O]_)-,.-~*´¨¯¨`*·~-.¸
Vicis Posted January 13, 2008 Posted January 13, 2008 Try this: #include <GUIConstants.au3> $x = 0 $y = 0 $game = GUICreate("Game", 300, 300) $pic = GUICtrlCreateGraphic(150, 150, 5, 5) GUICtrlSetColor($pic, 0xff00000) GUICtrlSetBkColor($pic, 0xff0000) GUICtrlSetGraphic($pic, $GUI_GR_RECT, $x, $y, 5, 5) $left = GUICtrlCreateButton("Left", 1, 1, 40, 20) $right = GUICtrlCreateButton("Right", 42, 1, 40, 20) $up = GUICtrlCreateButton("Up", 83, 1, 40, 20) $down = GUICtrlCreateButton("Down", 124, 1, 40, 20) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $left $x -= 1 Case $right $x += 1 Case $up $y += 1 Case $down $y -= 1 EndSwitch GUICtrlSetPos($pic,150+$x,150-$y) ToolTip("X = " & $x & @LF & "Y = " & $y) WEnd I was just about to say the same. Use GUICtrlSetPos( $Graphic1, $x, $y)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now