Klick zone bewegt sich nicht mit

  • GM 8

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Klick zone bewegt sich nicht mit

    Hi,

    Ich hab seit einiger Zeit nen kleinen Bug und ich finde einfach nicht den fehler.
    Undzwar hab ich ein Inventar das ich mit der Maus hin und her verschieben kann.

    Das hab ich wiefolgt, relativ simple gelöst:

    create

    GML-Quellcode

    1. geklickt=false;

    step

    GML-Quellcode

    1. if geklickt&&global.inv_select=0
    2. {
    3. x = mouse_x - mx;
    4. y = mouse_y - my;
    5. }

    left pressed

    GML-Quellcode

    1. geklickt = true;
    2. mx = mouse_x - x;
    3. my = mouse_y - y;

    left released

    GML-Quellcode

    1. geklickt = false

    draw event

    GML-Quellcode

    1. draw_sprite_part(sprite_index,image_index,0,0,305,370,x+view_xview[0],y+view_yview[0])


    Das funktioniert auch alles wunderbar, nur wenn sich der View jetzt verändert scheint die "klick-zone" nicht mitzugehen.
    Das Inventar bewegt sich zwar mit dem View aber ich muss jetzt links neben das Inventar klicken um es zu verschieben.
    Hab mal eine Skizze angehängt.

    Also wo ist hier der Wurm drin?
    Bilder
    • sizze_bug.png

      8,5 kB, 250×150, 85 mal angesehen
    Imagine taking your usual two century long nap minding your own business when suddenly some cunt wakes you up.
    You tell him to f*ck off of course but just when you finally managed to fall asleep again the same asshole comes knocking again. I'd attack that dick too.
  • Leider scheint dies keinen unterschied zu machen. :s
    Imagine taking your usual two century long nap minding your own business when suddenly some cunt wakes you up.
    You tell him to f*ck off of course but just when you finally managed to fall asleep again the same asshole comes knocking again. I'd attack that dick too.
  • @kebaplover
    Das ändert leider auch garnix, ist nach wie vor dasselbe.
    Ich versteh einfach nicht wie dieser Bug zustande kommt. :pinch:

    @Tice
    Was kann man da den groß falsch machen?
    Soweit ich verstanden hab ist window_mouse_get_x() dasselbe wie mouse_x nur auf das Window fenster bezogen.
    Ich hab einfach mouse_x mit window_mouse_get_x() und mouse_y mit window_mouse_get_y() ersetzt.
    Imagine taking your usual two century long nap minding your own business when suddenly some cunt wakes you up.
    You tell him to f*ck off of course but just when you finally managed to fall asleep again the same asshole comes knocking again. I'd attack that dick too.
  • Step

    GML-Quellcode

    1. var mx, my;
    2. mx = window_mouse_get_x();
    3. my = window_mouse_get_y();
    4. hover = ((mx >= bbox_left && mx <= bbox_right) && (my >= bbox_top && my <= bbox_bottom));
    5. if (hover && mouse_check_button_pressed(mb_left) && !dragging)
    6. {
    7. dragging = true;
    8. offset_x = x - mx;
    9. offset_y = y - my;
    10. }
    11. if (mouse_check_button_released(mb_left)) dragging = false;
    12. if (dragging)
    13. {
    14. x = mx + offset_x;
    15. y = my + offset_y;
    16. }
    Alles anzeigen
    (Sollte klappen)
    die Mouse-Events benutzen mouse_x/y
    Daher den detection code selber schreiben, ist sowieso schöner
    :saint:
  • Perfekt danke!
    Funktioniert jetzt einwandfrei.
    Der bbox befehl war mir neu aber man kann ja nicht alle kennen, muss mal etwas öfters reingucken was es so alles an befehlen gibt. :D
    Imagine taking your usual two century long nap minding your own business when suddenly some cunt wakes you up.
    You tell him to f*ck off of course but just when you finally managed to fall asleep again the same asshole comes knocking again. I'd attack that dick too.
  • Benutzer online 1

    1 Besucher