animation steuert anderes obj

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

  • animation steuert anderes obj

    moin!in meinem sidescroller shmup gibt es eine höhle mit feuer, das mit einem lichtobject erhellt wird. ich habe 4 feuerobjekte im room gesetzt, wobei nur beim 4. objekt das licht korrekt ein/ausgeschaltet wird. das licht soll nur eingeschaltet sein, wenn die flamme sichtbar ist, was ich mit sprite_index von obj_fire abfrage.

    gelöst habe ich es folgendermaßen im step-event von obj_fire:

    GML-Quellcode

    1. ///light on/off with fireAnimation
    2. if image_index > 0 and image_index < 1 {
    3. instance_create(obj_fire.x, obj_fire.y, obj_licht);
    4. }
    5. if image_index > 18 and image_index < 19 {
    6. with (obj_licht) { instance_destroy(); }
    7. }




    das ganze funktioniert auch wie gewollt, jedoch nur beim 4. obj_fire.woran könnte das liegen? gäbe es eine geschicktere lösung?
  • Du musst

    GML-Quellcode

    1. with (obj_fire)

    benutzen und da das instance create reinpacken, ansonsten referenzierst du logischer weise nur eine "zufällige" Instanz des Objekts, in dem Fall das letzte was erzeugt wurde.

    EDIT:
    so:

    GML-Quellcode

    1. if (floor(image_index) = 0) {
    2. with (obj_fire) {
    3. instance_create(x, y, obj_licht);
    4. }
    5. }
    6. if (floor(image_index) = 18) {
    7. with (obj_licht) {
    8. instance_destroy();
    9. }
    10. }

    132 little bugs in the code. 132 little bugs. Fix a few, set the compiler to stew, 172 little bugs in the code... :vogel:

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Rhazul ()