Navigation

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

    Sprite animation loops constantly? Need it to stop!

    Help
    6
    13
    498
    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.
    • waldron
      waldron F @Martin last edited by

      @Martin yeah i need to start doing this delete sprite its just taking the plunge

      1 Reply Last reply Reply Quote 0
      • M
        MikeDX last edited by MikeDX

        Just a side note

        The following code "should" do exactly the same and not use a sprite slot

        // Do whatever you need to do
        // In your loop you can now say
        for n = 0 to len(enemies) loop
            if enemies[n] != false then
                // do all your stuff, including when you're done with it...
                removeSprite(enemies[n])
                enemies[n] = false
            endif
        repeat
        

        I just realised why this doesn't work and I am going to try to get it addressed in a future patch as to me it is very odd behaviour and 100% cannot be "by design"

        You cannot compare a sprite object to anything other than another sprite object, so setting it to false , null, void, 1, "nothing" or anything else will not work... hence the requirement for an empty sprite

        1 Reply Last reply Reply Quote 1
        • SwitchedOn
          SwitchedOn last edited by

          Thanks for all the replies, I'll check them out today!

          Just had a thought laying here after just waking up, and that is;

          // Do whatever you need to do
          // In your loop you can now say
          for n = 0 to len(enemies) loop
          if enemies[n].sprite != visible then
          If explosionSprite[n] frame count>60
          removeSprite(enemies[n])
          Endif
          endif
          repeat

          As only destroyed aliens will ever be exploding?...

          Anyways, thaanjs again. Will update how it's gone :)

          spikey 1 Reply Last reply Reply Quote 2
          • SwitchedOn
            SwitchedOn last edited by

            the above worked fine by the way, thanks for all the pointers @Martin and @MikeDX

            1 Reply Last reply Reply Quote 0
            • spikey
              spikey F @SwitchedOn last edited by

              @SwitchedOn sorry I did not look up the docs, but what is the variable visible? Is this pseudo code?

              SwitchedOn 1 Reply Last reply Reply Quote 0
              • D
                doumdoum F last edited by

                @SwitchedOn
                As soon as i hit an enemy, i put it outside the screen area and make it static.

                sprite.y = -10000// shoud be enough to avoid any collision with other sprites
                setSpriteSpeed( sprite, {0.0} ) // i don't want the enemy to come back in the screen
                

                I don't delete the sprite,

                M 1 Reply Last reply Reply Quote 1
                • SwitchedOn
                  SwitchedOn @spikey last edited by

                  @spikey said in Sprite animation loops constantly? Need it to stop!:

                  @SwitchedOn sorry I did not look up the docs, but what is the variable visible? Is this pseudo code?

                  Yea it is, but its a 'get'

                  getSpriteVisibility(spriteName)

                  Can also use a 'set'

                  setSpriteVisibility(sprintName, Boolean)

                  1 Reply Last reply Reply Quote 1
                  • M
                    MikeDX @doumdoum last edited by

                    @doumdoum said in Sprite animation loops constantly? Need it to stop!:

                    @SwitchedOn
                    As soon as i hit an enemy, i put it outside the screen area and make it static.

                    sprite.y = -10000// shoud be enough to avoid any collision with other sprites
                    setSpriteSpeed( sprite, {0.0} ) // i don't want the enemy to come back in the screen
                    

                    I don't delete the sprite,

                    Whilst this works, I wouldn't approve of this as a best practice way of doing things.

                    SwitchedOn 1 Reply Last reply Reply Quote 0
                    • SwitchedOn
                      SwitchedOn @MikeDX last edited by

                      @MikeDX said in Sprite animation loops constantly? Need it to stop!:

                      @doumdoum said in Sprite animation loops constantly? Need it to stop!:

                      @SwitchedOn
                      As soon as i hit an enemy, i put it outside the screen area and make it static.

                      sprite.y = -10000// shoud be enough to avoid any collision with other sprites
                      setSpriteSpeed( sprite, {0.0} ) // i don't want the enemy to come back in the screen
                      

                      I don't delete the sprite,

                      Whilst this works, I wouldn't approve of this as a best practice way of doing things.

                      Yep, could end up being a bit of a memory hog - plus as they are still active to a degree, could cause issues in detections etc.

                      1 Reply Last reply Reply Quote 0
                      • D
                        doumdoum F last edited by

                        In practice, in a space invader/galaxian game, i have a constant number of enemies (50 max).
                        I recycle the sprites on the next stage, only by changing properties.(ecolo coding)
                        Since the sprites are static and far away, they don't collide with bullets, Ships etc.
                        I do the same with bullets, explosions.
                        I admit it's a rough method, but it works well.
                        Give me stack and list, and i'll make it better.

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