Problem mit Distanzabfrage

  • GM 8

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

  • Problem mit Distanzabfrage

    Hallo liebe Game Maker Community,

    ich habe ein "erweitertes" problem mit einer distanzabfrage zu bekämpfen. Ich habe drei sprites (Zug Sprite + 2 Türen)

    Am anfang fahre alle gleich los bleiben dann bei einer bestimmten stelle stehen und nach ablauf einer bestimmten zeit öffnen sich die Türen.
    Ist wieder eine bestimmte zeit verstrichen schließen sie sich wieder und hier kommt das problem: Der Zug fährt ab aber die Türen bleiben da...

    könnt ihr mir hierbei helfen?

    // Create

    GML-Quellcode

    1. global.door_wait[0] = 40
    2. global.door_wait[1] = 40
    3. global.door_closing = 0


    // Step

    GML-Quellcode

    1. // DOORS FOLLOW LEFT
    2. if id = inst_D71289A2
    3. if global.door_wait[0] = 40
    4. if x>828
    5. {
    6. x-=8
    7. }
    8. if id = inst_D71289A2
    9. if x = 828
    10. {
    11. global.door_wait[0] -=0.1
    12. }
    13. if id = inst_D71289A2
    14. if global.door_wait[0] = 0
    15. {
    16. x-=8
    17. }
    18. // DOORS FOLLOW RIGHT
    19. if id = inst_7468B381
    20. if global.door_wait[1] = 40
    21. if x>902
    22. {
    23. x-=8
    24. }
    25. if id = inst_7468B381
    26. if x = 902
    27. {
    28. global.door_wait[1] -=0.1
    29. }
    30. if id = inst_7468B381
    31. if global.door_wait[1] = 0
    32. {
    33. x-=8
    34. }
    35. // Door Opening
    36. if id = inst_D71289A2
    37. if global.door_wait[0]<30
    38. if global.door_closing = 0
    39. {
    40. x-=4
    41. }
    42. if id = inst_D71289A2
    43. if global.door_wait[0]<30
    44. {
    45. if x<752
    46. x=752
    47. global.door_wait[0] -=0.1
    48. }
    49. if id = inst_7468B381
    50. if global.door_wait[1]<30
    51. if global.door_closing = 0
    52. {
    53. x+=4
    54. }
    55. if id = inst_7468B381
    56. if global.door_wait[1]<30
    57. {
    58. if x>977
    59. x=977
    60. global.door_wait[1] -=0.1
    61. }
    62. // Not negative
    63. if global.door_wait[0]<10
    64. global.door_closing = 2
    65. if global.door_wait[1]<10
    66. global.door_closing = 2
    67. if global.door_wait[0] <0
    68. global.door_wait[0] = 0
    69. if global.door_wait[1] <0
    70. global.door_wait[1] = 0
    71. // Door Closing
    72. if id = inst_D71289A2
    73. if global.door_wait[0]<20
    74. if global.door_closing = 2
    75. {
    76. x+=4
    77. }
    78. if id = inst_D71289A2
    79. if global.door_wait[0]<20
    80. {
    81. if x>828
    82. x=828
    83. }
    84. if id = inst_7468B381
    85. if global.door_wait[1]<20
    86. if global.door_closing = 2
    87. {
    88. x-=4
    89. }
    90. if id = inst_7468B381
    91. if global.door_wait[1]<20
    92. {
    93. if x<902
    94. x=902
    95. }
    Alles anzeigen
  • ich hatte jetzt leider nicht die Zeit deinen gesamten Code im Detail zu analysieren, aber mir ist beim überfliegen aufgefallen, dass du die x-Position absolut setzt.. oder irre ich mich da, und hab etwas übersehen? Falls nicht, solltest du die Türposition besser in Abhängigkeit der Waggons handhaben.

    also x = id.x + offset