Navigation

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

    Finding it hard to get enemies

    Help
    5
    27
    1742
    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.
    • lawyerlounge
      lawyerlounge last edited by

      What is the main difference from Dave's example (2 posts up) and my example (which both at some point have the setSpriteAnimation() function inside of the main loop) that would cause his to work and mine not to.

      Other than having "if statements" (which basically change a variable called "state" which in turn changes the startFrame and endFrame vars for the arguments within setSpriteAnimation), and providing a check to see if the current state is not what it used to be, what causes the program in Dave's post to let the animation run from start to finish without constantly executing the beginning of the animation? (the problem you dissected within my example)

      Or is the method of checking if state != oldState required, because if you intend an animation to change throughout the main loop you need to find a way to only run it once at particular moments? And for any asset that doesn't need to change animations you would just use the setSpriteAnimation function before the main loop and set the visibility to false until needing to display?

      I think I've figured out the bare requirements for using sSA() in the loop... would this work?

      sprite = createSprite()
      setSpriteImage( sprite, image)
      setSpriteLocation(sprite, gwidth()/2, gheight()/2)
      startFrame = 0
      endFrame  = 10
      fps = 10
      
      animSwitch = true
      
      Loop
            clear()
           
            currentFrame = getSpriteAnimFrame( sprite )
      
            if animSwitch then
                  setSpriteAnimation( sprite, startFrame, endFrame, fps)
                  animSwitch = false
            endif
      
            if currentFrame >= endFrame then
                  animSwitch = true
            endif
      
            updateSprites()
            drawSprites()
      
            update()
      repeat
      

      P.S. thank you for all of the help teaching me something that must be simple for you guys!
      -MikeV

      pianofire 1 Reply Last reply Reply Quote 0
      • pianofire
        pianofire Fuze Team @lawyerlounge last edited by

        @lawyerlounge Not at all. That's what we are here for. Yes you only want to call setSpriteAnimation to change the current animation. The set animation will be repeated until a new one is set. If you want more control over the animation you can use setSpriteAnimFrame but you will have to control the speed yourself:

        https://fuzearena.com/help/view/setSpriteAnimFrame

        1 Reply Last reply Reply Quote 2
        • lawyerlounge
          lawyerlounge last edited by

          Nice! so my example should display the animation on loop? (not at home yet to test it)

          pianofire 1 Reply Last reply Reply Quote 0
          • pianofire
            pianofire Fuze Team @lawyerlounge last edited by

            @lawyerlounge Well I haven't tried it but yes it looks like it should

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

              @Jonboy haha i must be to nice

              1 Reply Last reply Reply Quote 1
              • Jonboy
                Jonboy Fuze Team last edited by

                ha, but not TOO nice. See, i did it again. Seriously, you should not invite me to comment :-)

                1 Reply Last reply Reply Quote 1
                • Dave
                  Dave Fuze Team last edited by

                  @lawyerlounge My bad! Completely forgot about perhaps the most important command, drawSprites(), in the example I gave.

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