cppman Posted February 18, 2006 Share Posted February 18, 2006 (edited) Im trying to make $controlID move to the coordinates $x and $y. could anyone help me out, to tell me how i could do this? Global $Image, $Width, $Height, $StartX, $StartY Func SpriteCreate($Image, $Width, $Height, $StartX, $StartY) Global $controlID $controlID = GUICtrlCreatePic($Image, $StartX, $StartY, $Width, $Height) If $controlID Then Return $controlID Else SetError(1) Return 0 EndIf EndFunc Func SpriteMove($controlID, $x, $y); move to x and y position EndFunc GUICreate("Game Sample", 500, 500, -1, -1) GUISetBkColor(0x000000) GUIsetState() $Sprite = SpriteCreate("sprite.jpg", 25, 25, 15, 15) sleep(1000) SpriteMove($Sprite, 200, 15) While 1 WEnd yeah, i no, my functions should be after the while loop. but i did this so because i was in the middle of writing this udf and wanted to test it out real quick.... Edited February 18, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
GaryFrost Posted February 18, 2006 Share Posted February 18, 2006 (edited) #include <GuiConstants.au3> Global $Image, $Width, $Height, $StartX, $StartY Func SpriteCreate($Image, $Width, $Height, $StartX, $StartY) Global $controlID $controlID = GUICtrlCreatePic($Image, $StartX, $StartY, $Width, $Height) If $controlID Then Return $controlID Else SetError(1) Return 0 EndIf EndFunc ;==>SpriteCreate Func SpriteMove($controlID, $x, $y); move to x and y position GUICtrlSetPos($controlID, $x, $y) EndFunc ;==>SpriteMove GUICreate("Game Sample", 500, 500, -1, -1) GUISetBkColor(0x000000) GUISetState() $Sprite = SpriteCreate("sprite.jpg", 25, 25, 15, 15) Sleep(1000) SpriteMove($Sprite, 200, 15) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Edited February 18, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
cppman Posted February 18, 2006 Author Share Posted February 18, 2006 o... wow, i completely forgot about the GUICtrlSetPos() command..... thanks alot! Miva OS Project Link to comment Share on other sites More sharing options...
cppman Posted February 18, 2006 Author Share Posted February 18, 2006 okay, i had one more question, how would i make it so it MOVES and u can see it MOVE, not just jump top that position....? Miva OS Project Link to comment Share on other sites More sharing options...
GaryFrost Posted February 18, 2006 Share Posted February 18, 2006 example: #include <GuiConstants.au3> Global $Image, $Width, $Height, $StartX, $StartY Func SpriteCreate($Image, $Width, $Height, $StartX, $StartY) Global $controlID $controlID = GUICtrlCreatePic($Image, $StartX, $StartY, $Width, $Height) If $controlID Then Return $controlID Else SetError(1) Return 0 EndIf EndFunc ;==>SpriteCreate Func SpriteMove($controlID, $x, $y); move to x and y position GUICtrlSetPos($controlID, $x, $y) EndFunc ;==>SpriteMove GUICreate("Game Sample", 500, 500, -1, -1) GUISetBkColor(0x000000) GUISetState() $Sprite = SpriteCreate("sprite.jpg", 25, 25, 15, 15) For $x = 25 To 200 SpriteMove($Sprite, $x, 15) Sleep ( 10 ) Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
cppman Posted February 18, 2006 Author Share Posted February 18, 2006 I get what your doing but im still a little confused... sry to keep buggin you, but how would i make it move to the position X and Y like SpriteMove($Sprite, $x, $y) ; moves $Sprite to position x y ??? btw, i really really appreciate your help! Miva OS Project Link to comment Share on other sites More sharing options...
GaryFrost Posted February 18, 2006 Share Posted February 18, 2006 (edited) #include <GuiConstants.au3> Global $Image, $Width, $Height, $StartX, $StartY Func SpriteCreate($Image, $Width, $Height, $StartX, $StartY) Global $controlID $controlID = GUICtrlCreatePic($Image, $StartX, $StartY, $Width, $Height) If $controlID Then Return $controlID Else SetError(1) Return 0 EndIf EndFunc ;==>SpriteCreate Func SpriteMove($controlID, $x, $y); move to x and y position GUICtrlSetPos($controlID, $x, $y) EndFunc ;==>SpriteMove GUICreate("Game Sample", 500, 500, -1, -1) GUISetBkColor(0x000000) GUISetState() $Sprite = SpriteCreate("sprite.jpg", 25, 25, 15, 15) $y = 25 For $x = 25 To 200 SpriteMove($Sprite, $x, $y) Sleep ( 10 ) $y = $y + 1 Next ;~ Sleep(1000) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Edited February 18, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 18, 2006 Moderators Share Posted February 18, 2006 Hey Chris... FYI... Take a look at your signature, your returning a decimal value but calling it a Hex value in the variable nameWhile 1 Local $Mouse = MouseGetPos() Local $MouseX = $Mouse[0] Local $MouseY = $Mouse[1] Local $ColorHex = PixelGetColor($MouseX, $MouseY) TrayTip("information", "Mouse X Position: " & $MouseX & @CRLF & "Mouse Y Position: " & $MouseY & @CRLF & "Hex Color: 0x" & Hex($ColorHex, 6), 0) Sleep(10) WEnd would fix it . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
cppman Posted February 18, 2006 Author Share Posted February 18, 2006 Hey Chris... FYI... Take a look at your signature, your returning a decimal value but calling it a Hex value in the variable nameWhile 1 Local $Mouse = MouseGetPos() Local $MouseX = $Mouse[0] Local $MouseY = $Mouse[1] Local $ColorHex = PixelGetColor($MouseX, $MouseY) TrayTip("information", "Mouse X Position: " & $MouseX & @CRLF & "Mouse Y Position: " & $MouseY & @CRLF & "Hex Color: 0x" & Hex($ColorHex, 6), 0) Sleep(10) WEnd would fix it . oh, woops. thanks for pointing that out... Miva OS Project Link to comment Share on other sites More sharing options...
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