Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    How do I Delay something?

    Help
    3
    11
    682
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 91Pkay
      91Pkay last edited by

      So I want to have a delay before a sound effect plays. How do I do this? I tryed using sleep but that delays the WHOLE program, so sleep didn’t work.

      1 Reply Last reply Reply Quote 0
      • waldron
        waldron F last edited by

        Hard to say with out knowing what the sound is for, you could add a timer

        If timer >= 5 and timer <= 5.2 then
        Playaudio()
        Endif
        or if your wanting
        It to trigger for a specific spriteframe in animation you can use
        If getspriteanimframe(plr) >= 5 and getspriteanimframe(plr) <= 6 then
        Playaudio()
        Endif
        If your using the map editor you could add detectmaparea() and trigger it that way.

        91Pkay 1 Reply Last reply Reply Quote 0
        • 91Pkay
          91Pkay @waldron last edited by

          @waldron what’s the timer variable for? Like what do I put in, timer = (?)

          Here’s my code and the problem.

          image.jpg

          image.jpg

          1 Reply Last reply Reply Quote 0
          • waldron
            waldron F last edited by

            Hey, the timer could be set as a variable like
            You have for pan, speed ect.
            Timer = 0
            Then in your main loop
            Put the if statement in there then
            You need to manipulate the timer variable else it would stay at 0 so also in your main loop try this.
            Timer += .1
            If timer >= 6 then
            Timer = 0
            Endif
            The values are just examples plus you could use print(int(timer)) to help with testing.

            91Pkay 1 Reply Last reply Reply Quote 0
            • 91Pkay
              91Pkay @waldron last edited by

              @waldron Sorry I’m a beginner and I still really don’t understand 😑

              waldron 1 Reply Last reply Reply Quote 0
              • vinicity
                vinicity F last edited by vinicity

                Here is how I would do it:
                2023041821271700-86FC867622BE2C2315A009D470F52DAE.jpeg

                1 Reply Last reply Reply Quote 1
                • vinicity
                  vinicity F last edited by

                  Or here is another way to do it. This time I used Fuze’s built-in setTimer() function instead. That can be used to trigger any function after a chosen time…
                  2023041821352800-86FC867622BE2C2315A009D470F52DAE.jpeg

                  1 Reply Last reply Reply Quote 0
                  • vinicity
                    vinicity F last edited by vinicity

                    Let me know if you have any questions!

                    (Also, a great tip is to indent the code to make it easier to read. Put a tab before each line of code within a code block.)

                    91Pkay 1 Reply Last reply Reply Quote 0
                    • waldron
                      waldron F @91Pkay last edited by

                      @91pkay that's fine it can take a few attempts until things sink in, hopefully vicinitys examples help.

                      1 Reply Last reply Reply Quote 1
                      • 91Pkay
                        91Pkay @vinicity last edited by

                        @vinicity is it possible to do with anything, for example loadmap() ?

                        1 Reply Last reply Reply Quote 0
                        • vinicity
                          vinicity F last edited by

                          All that setTimer does is tell Fuze to call a user function after a set time. That user function may of course contain anything you want, like loadMap().

                          The same goes for the other example. You can put whatever inside the delayed functions...

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post