instance_place - instance_destroy

  • instance_place - instance_destroy

    Hey.
    Ich komme mal direkt auf den Punkt.^^
    Ich habe Blöcke die nebeneinander stehen. In jedem Block wird abgefragt, ob rechts, links, oben oder unten ein anderer Block ist. Ich denke jeder weiß was gemeint ist;)
    Ich speicher die ids dieser Blöcke in id1, id2, id3 und id4. Abgefragt wird im Stepevent mit instance_place (if instance_place(x+16,y,block) {id1=instance_place(x+16,y,block))

    Wenn ich auf den Block klicke wird er zerstört. Im Destroyevent sollten auch die instancen id1, id2, id3 und id4 zerstört werden, jedoch klappt es einfach nicht. Manchmal wird nur der Block auf den geklickt wird zerstört, ein anderes mal auch der daneben, jedoch nie alle, die sollen-.-

    Ich kann ja mal die Datei anhängen (*.gmk)
    Dateien
    • puzzle.rar

      (6,36 kB, 213 mal heruntergeladen, zuletzt: )
  • Ich kann dir helfen, wenn du das als *.gm6 anbietest!
    Kleiner Tipp: Ich arbeite gerade auch an einem Puzzle Spiel!
    Wenn du versuchst meins nachzumachen, dann lass es bleiben!
    Außerdem klappt das nicht, so wie du das machst.
    Schon mal was von Arrays gehört?
    57 6F 77 2C 20 64 61 73 20 68 61 73 74 20 64 75 20 67 61 6E 7A 20 61 6C 6C 65 69 6E 20 67 65 73 63 68 61 66 66 74 2E 20

    Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von DanielGM61 ()

  • GML-Quellcode

    1. with (id1) instance_destroy();
    2. with (id2) instance_destroy();
    3. with (id3) instance_destroy();
    4. with (id4) instance_destroy();
    5. //als letztes den angeglickten block zerstören
    6. instance_destroy()
    PI 0%(IN PROGRESS)
    [IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII]
    [IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII]

    Engine : 0.0 %
    KI : 0.0 %
    Grafik : 0.0%
    Sounds: 0.0 %
    Multiplayer: 0.0%
  • Original von DanielGM61
    Ich kann dir helfen, wenn du das als *.gm6 anbietest!
    Kleiner Tipp: Ich arbeite gerade auch an einem Puzzle Spiel!
    Wenn du versuchst meins nachzumachen, dann lass es bleiben!
    Außerdem klappt das nicht, so wie du das machst.
    Schon mal was von Arrays gehört?


    Erstens: Ich möchte niemandem etwas nachmachen. Zudem ist das nur eine kleine "Vorübung" damit das, was ich wirklich machen will auch funktioniert, aber wenn das so schon nicht geht...

    Zweitens: Falls du dies eine da meinst, welches du selber abgeguckt hast (so weit ich weiß, von nem DS-Spiel?!), würde ich ganz leise bleiben.

    Drittens: Ja ich habe schonmal was von Arrays gehört. Bin nicht dumm!


    @bigmek: Genau so hab ich das ja gemacht. Jedoch geht das nicht. Der zerstört nie alle.
  • hast du schon überprüft ob die id1 bis id4 auch richtig befüllt wird?
    PI 0%(IN PROGRESS)
    [IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII]
    [IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII]

    Engine : 0.0 %
    KI : 0.0 %
    Grafik : 0.0%
    Sounds: 0.0 %
    Multiplayer: 0.0%
  • Das sind die relevanten Informationen:

    Quellcode

    1. Create Event:
    2. execute code:
    3. farbe=choose(c_red,c_yellow,c_lime,c_blue)
    4. id1=""
    5. id2=""
    6. id3=""
    7. id4=""
    8. Destroy Event:
    9. execute code:
    10. if instance_exists(id1) with id1 instance_destroy()
    11. if instance_exists(id2) with id2 instance_destroy()
    12. if instance_exists(id3) with id3 instance_destroy()
    13. if instance_exists(id4) with id4 instance_destroy()
    14. Step Event:
    15. execute code:
    16. a=0
    17. if instance_place(x+16,y,block)
    18. {
    19. i=instance_place(x+16,y,block)
    20. if i.farbe=farbe{id1=i;a+=1}
    21. }
    22. if instance_place(x-16,y,block)
    23. {
    24. i=instance_place(x-16,y,block)
    25. if i.farbe=farbe{id2=i;a+=1}
    26. }
    27. if instance_place(x,y+16,block)
    28. {
    29. i=instance_place(x,y+16,block)
    30. if i.farbe=farbe{id3=i;a+=1}
    31. }
    32. if instance_place(x,y-16,block)
    33. {
    34. i=instance_place(x,y-16,block)
    35. if i.farbe=farbe{id4=i;a+=1}
    36. }
    37. Mouse Event for Left Pressed:
    38. execute code:
    39. instance_destroy()
    40. Draw Event:
    41. execute code:
    42. draw_sprite_ext(sprite_index,image_single,x,y,1,1,0,farbe,1)
    43. draw_text(x,y,a)
    Alles anzeigen