Sprite index variable

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

  • Sprite index variable

    Hi,

    Im create event wähle ich den kopf eines charakters zufällig.

    GML-Quellcode

    1. cl[1]=head1;
    2. cl[2]=head2;
    3. cl[3]=head3;
    4. cl[4]=head4;
    5. i=choose(1,2,3,4)
    6. head=cl[i]
    7. sprite_index=head;
    8. walk=false;


    im Step event hab ich nun versucht in die lauf animation zu wechseln. (head1_walk, head2_walk etc.)

    GML-Quellcode

    1. if(walk)
    2. {
    3. sprite_index=string(head)+"_walk";
    4. }


    Dies funktioniert natürlich nicht, wie stelle ich es an?
    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.

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

  • Gibts noch nen anderen Weg?
    Game Maker 8 verfügt über solche funktionen nicht. :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.
  • Das weiß ich nciht, aber ich habe sowas früher immer über mehrere variablen gelöst.

    GML-Quellcode

    1. head_art = spr..
    2. body_art = spr...


    also mit der Entscheidung welcher Kopf gewählt wird wird die gehanimation, der Körper etc mitgewählt und je nach Input wird dann die jeweilige variable im draw-sprite() benutzt.

    ancient-pixel.com
    youtube.com/user/SebastianMerkl <<< ich freu mich über einen Besuch ;)
  • Ich verstehe, so ähnlich hatte ich es auch vorher aber wollte es vereinfachen da das ne ganze Menge an Code ist wenn man 10+ Animationen hat und 5 verschiedene Köpfe.

    Vielleicht hat sonst noch jemand ne Idee wie man es vereinfachen könnte?
    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.
  • Genau so etwas hab ich doch gemacht.
    head1, head2 etc sind bereits sprites undzwar die steh sprites.
    Es geht darum das wenn im Create Event der head1 sprite ausgewählt wird er dann automatisch auch auf head1_walk, head1_attack und so weiter ändert.
    Ich wollte halt eine einfache Methode aber anscheinend geht das nicht ohne Zusätzliche Variablen und diverse if abragen. Zumindest nicht mit dem GM8.
    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.
  • Ich hab eine Möglichkeit gefunden. Ich hab dir mal ein Skript geschrieben:

    GML-Quellcode

    1. ///asset_get_index(name)
    2. argument0 = string(argument0);
    3. var i;
    4. for(i = 0; sprite_exists(i); i ++){
    5. if sprite_get_name(i) == argument0
    6. return i;
    7. }
    8. for(i = 0; sound_exists(i); i ++){
    9. if sound_get_name(i) == argument0
    10. return i;
    11. }
    12. for(i = 0; background_exists(i); i ++){
    13. if background_get_name(i) == argument0
    14. return i;
    15. }
    16. for(i = 0; path_exists(i); i ++){
    17. if path_get_name(i) == argument0
    18. return i;
    19. }
    20. for(i = 0; script_exists(i); i ++){
    21. if script_get_name(i) == argument0
    22. return i;
    23. }
    24. for(i = 0; font_exists(i); i ++){
    25. if font_get_name(i) == argument0
    26. return i;
    27. }
    28. for(i = 0; timeline_exists(i); i ++){
    29. if timeline_get_name(i) == argument0
    30. return i;
    31. }
    32. for(i = 0; object_exists(i); i ++){
    33. if object_get_name(i) == argument0
    34. return i;
    35. }
    36. for(i = 0; room_exists(i); i ++){
    37. if room_get_name(i) == argument0
    38. return i;
    39. }
    40. return undefined;
    Alles anzeigen


    Einfach als Skript einfügen und dann hast du die Funktion auch.

    Edit: gibt es in gm8 auch undefined? ansonsten mach daraus z.B. -1
    Ein Bug ist mehr als nur ein Bug, es ist ein... Käfer!
    Egal, wie gut du eine Mauer baust, sie fällt um.... der klügere gibt nach :D

    Willst du mit mir auf Discord Chatten/Quatschen?
    Meine Husi's Tutorial Reihe