ControlMove

  • Hallo ich will ein Bild für ein Spiel Bewegen

    [autoit]

    ...
    If _IsPressed(28) Then
    $up = $up + 1
    If $pic = 4 Then
    ControlMove ("","",$del,$right,$up)
    EndIf ;die variablen müssten alle stimmen
    ...

    [/autoit]

    Mein Problem:
    Edit: geändert wegen falscher aussage.
    Das bewegen funktioniert Nicht

    Danke im vorraus

    mfg Ubuntu

  • was soll ich sagen....ausser RTFM! :cursing:

  • Hallo Ubuntu,

    versuch es einmal so:

    [autoit]

    ...
    while _IsPressed(28)
    $up = $up + 1
    If $pic = 4 Then
    ControlMove ("","",$del,$right,$up)
    Wend ;die variablen müssten alle stimmen
    ...

    [/autoit]

    da ich vermute, dass die Bewegung um 1 Pixel nicht auffällt. Ansonsten poste mal dein ganzes Skript,

    mfg (Auto)Bert

  • Spoiler anzeigen
    [autoit]

    ;left arrow 25
    ;up arrow 26
    ;right arrow 27
    ;down arrow 28
    ;space bar 20
    #include <GuiConstants.au3>
    #include <Misc.au3>

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

    GUICreate ("Bubble")
    GUISetBkColor(0x000000)
    $del = GUICtrlCreatePic(@ScriptDir & "\packman right.gif", 50, 50,20,20)
    If $del = 0 Then MsgBox(0,"ERROR","Error, kann die Bilddatei nicht finden.")
    GuiSetState(@SW_SHOW)

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

    $up = 50;+ weiter unten- weiter oben 2.Wert
    $right = 50 ;+ weiter rechts - weiter links 1.Wert
    $pic = 1;1 Rechts , 2 Links , 3 Oben , 4 Unten

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

    While 1
    If _IsPressed(26) Then
    GUICtrlDelete ($del)
    $up = $up -1
    $del = GUICtrlCreatePic(@ScriptDir & "\packman right.gif", $right, $up,20,20)
    EndIf

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

    If _IsPressed(25) Then
    GUICtrlDelete ($del)
    $right = $right -1
    $del = GUICtrlCreatePic(@ScriptDir & "\packman right.gif", $right, $up,20,20)
    EndIf

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

    If _IsPressed(28) Then
    #cs $up = $up + 1
    If $pic = 4 Then
    ControlMove ("","",$del,$right,$up)
    EndIf
    #ce
    GUICtrlDelete ($del)
    $up = $up +1
    $del = GUICtrlCreatePic(@ScriptDir & "\packman right.gif", $right, $up,20,20)
    EndIf

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

    If _IsPressed(27) Then
    $right = $right +1
    GUICtrlDelete ($del)
    $del = GUICtrlCreatePic(@ScriptDir & "\packman right.gif", $right, $up,20,20)
    EndIf

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

    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

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

    WEnd

    [/autoit]

    Das ist der Code.
    Ist nur der Anfang aber mehr hab ich noch nicht.
    Wie man sieht flackert das bild immer wieder.
    Ich dachte mit Control Move ist das vllt. anders.

    Unten das Bild

  • Hallo Ubuntu,

    ohne GUICtrlDelete und GUICtrlCreatePic aber mit ControlMove flackerts nicht mehr:

    Spoiler anzeigen
    [autoit]

    ;left arrow 25
    ;up arrow 26
    ;right arrow 27
    ;down arrow 28
    ;space bar 20
    #include <GuiConstants.au3>
    #include <Misc.au3>

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

    GUICreate("Bubble")
    GUISetBkColor(0x000000)
    $del = GUICtrlCreatePic(@ScriptDir & "\packman right.gif", 50, 50, 20, 20)
    If $del = 0 Then MsgBox(0, "ERROR", "Error, kann die Bilddatei nicht finden.")
    GUISetState(@SW_SHOW)

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

    $up = 50;+ weiter unten- weiter oben 2.Wert
    $right = 50 ;+ weiter rechts - weiter links 1.Wert
    $pic = 1;1 Rechts , 2 Links , 3 Oben , 4 Unten

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

    While 1
    If _IsPressed(26) Then $up = $up - 1
    If _IsPressed(25) Then $right = $right - 1
    If _IsPressed(28) Then $up = $up + 1
    If _IsPressed(27) Then $right = $right + 1
    ControlMove("", "", $del, $right, $up)
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    [/autoit]


    mfg (Auto)Bert

    Einmal editiert, zuletzt von AutoBert (3. Dezember 2009 um 19:10)

  • @Ubuntu

    Zitat


    hab ich X( !!!


    NEIN, hast du NICHT! Du hast 5 Zeilen gepostet und als Fehlerbeschreibung "Das bewegen funktioniert Nicht".
    Komischerweise funktioniert das Bewegen einwandfrei! Dann muss es zwangsläufig an deinem Script liegen. Nur...welches Script?
    Wo ist das Problem in 5 Sätzen zu beschreiben was man gemacht hat, das Script zu posten und dann das Ziel bzw das Problem so zu beschreiben, daß man nicht erst nach zig-mal nachfragen mitbekommt um was es überhaupt geht!

    [autoit]

    #include <WinAPI.au3>

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

    $anz=10

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

    global $button[$anz+1],$x[$anz+1],$y[$anz+1]
    $gui=guicreate("Test",600,600)
    for $i=1 to $anz
    $button[$i]= guictrlcreatebutton($i,10+random(20,500,1),10+random(20,500,1),40,40)
    next
    guisetstate()

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

    adlibenable("_move",1000)

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

    while guigetmsg()<>-3
    for $i=1 to $anz
    $a=controlgetpos("Test","",$button[$i])
    if $a[0]<10 then $x[$i]=-$x[$i]
    if $a[1]<10 then $y[$i]=-$y[$i]
    if $a[0]>490 then $x[$i]=-$x[$i]
    if $a[1]>490 then $y[$i]=-$y[$i]
    controlmove("Test","",$button[$i],$a[0]+$x[$i],$a[1]+$y[$i],$a[0]/10,$a[0]/10)
    next
    ;_WinAPI_RedrawWindow($gui) ;hab nen langsamen Rechner ab 20 Controls wirds zu langsam,
    ;ggf kann man nur die Fläche der ontrols refreshen
    wend

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

    func _move()
    for $i=1 to $anz
    $x[$i]=random(-2,+2,1)
    $y[$i]=random(-2,+2,1)
    next
    endfunc

    [/autoit]

    Mal ein kleiner "Test" meinerseits zum Thema "flackern". Also bei mir flackert nix....

    /EDIT/ sry, du hast es heute abbekommen, hab mich wieder abgeregt!

  • Andi das hättest du auch früher sagen können ich hab die erste beschreibung gelöscht die zweite war dann schlicht falsch. In der Tat war mein Problem, dass das Bild geflackert hat.

    Ps: Entschuldigung Aktzeptiert

    mfg Ubuntu