Navigation

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

    Sprites - Help!

    Work In Progress
    8
    34
    1983
    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.
    • M
      MikeDX @Willpowered last edited by

      @Willpowered you've been global moderator for a long time!

      1 Reply Last reply Reply Quote 0
      • Willpowered
        Willpowered Fuze Team last edited by

        Okay, cool! Maybe I just had to refresh all this time... I think I've had the tab open for quite a while.

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

          apparently Martin made you mod and i thought you were already moderator 😃

          1 Reply Last reply Reply Quote 0
          • Martin
            Martin Fuze Team last edited by

            Grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr!!!!!!!!!!!!!!!!!!!!!!!!!!!

            Ignore the visible "issue"

            If I overlook the == vs. = one more time I swear I'm going to need a new Switch by the time it's bounced off the wall.

            pianofire 1 Reply Last reply Reply Quote 2
            • Willpowered
              Willpowered Fuze Team last edited by

              I figured it was something like that!

              I've added you using my personal Switch. If you have any more code you'd like looked at, let me know!

              1 Reply Last reply Reply Quote 0
              • Willpowered
                Willpowered Fuze Team last edited by

                By the way, you should be able to use removeSprite(sprite) to remove sprites that you're done with.

                In Super Mega Arena Blaster I handle this by also creating a dummy sprite that symbolizes a free space.

                For example, here's some pseudocode:

                nullsprite = createSprite() // create a placeholder sprite
                
                array enemies[10]
                for i = 0 to len(enemies) loop
                    // populate your enemies array here
                repeat
                
                // in your game loop...
                for i = 0 to len(enemies) loop
                    if enemies[i] != nullsprite then
                        // do your enemy logic here
                        if collideSprite(enemies[i], player).exists then
                            removeSprite(enemies[i]) // delete the sprite...
                            enemies[i] = nullsprite // ...and set it to null
                        endif
                    endif
                repeat
                

                Using a strategy like this, it's possible to make games with varying amounts of enemies / players / shots / etc. alive at any given time!

                1 Reply Last reply Reply Quote 1
                • T
                  TheDearHunter F last edited by

                  Could you post an example of how you are using collideMap to get detectSpriteCollision to work? I am also running into this issue where detection doesnt work if the collision shapes are hidden. Thanks

                  1 Reply Last reply Reply Quote 0
                  • Willpowered
                    Willpowered Fuze Team last edited by

                    Sure thing! First, you'll need to create an empty map using the map editor. Then in your code you'll need to load it with loadMap(map_name) and call collideMap(my_sprite) to refresh the collision data.

                    Here's how I would update the swimmer collision example earlier in this thread to work around the problem:

                    map = loadMap("test") // Load an empty map created with the map editor.
                    
                    img = loadImage("Untied Games/Swimmer A")
                    
                    spr1 = createSprite()
                    setSpriteImage(spr1, img)
                    setSpriteAnimation(spr1, 14, 27, 10)
                    setSpriteCollisionShape(spr1, SHAPE_CIRCLE, 100, 100, 0)
                    spr1.x = 1920 / 4
                    spr1.x_speed = -100
                    
                    spr2 = createSprite()
                    setSpriteImage(spr2, img)
                    setSpriteAnimation(spr2, 14, 27, 10)
                    setSpriteCollisionShape(spr2, SHAPE_CIRCLE, 100, 100, 0)
                    spr2.x = -1920 / 4
                    spr2.x_speed = 100
                    spr2.xscale = -1
                    
                    setSpriteCamera(0, 0, 4)
                    centerSpriteCamera(0, 0)
                    
                    while true loop
                        
                        clear(0, 0, 0, 0)
                    
                        // Colliding these sprites with an empty map will not affect them, but it will properly refresh their collision data.
                        collideMap(spr1)
                        collideMap(spr2)
                        
                        result = collideSprites(spr1, spr2)
                        if result.exists then
                            spr2.visible = false
                        endif
                        
                        updateSprites()
                        drawSprites()
                        update()
                        
                    repeat
                    
                    1 Reply Last reply Reply Quote 0
                    • T
                      TheDearHunter F last edited by

                      Ah i was only calling collideMap once and not in my game loop. This helped, thank you!

                      1 Reply Last reply Reply Quote 0
                      • Willpowered
                        Willpowered Fuze Team last edited by

                        Nice, glad you got it working! When I have an ETA on when the fix for this issue can be deployed, I'll let everyone know.

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

                          I have a question about sprite animation.

                          I have a sprite that is animating through frames correctly when idling.

                          When I detect control input say c.right I set the sprite animation to the corresponding right direction frames. And set the location. The sprite is moving to the right but no longer animates until I stop pressing c.right. I assume each time I update the sprite location it's resetting the animation to it's first frame.

                          I've looked at example code and can't spot what I am doing wrong.

                          Discostew 1 Reply Last reply Reply Quote 0
                          • Discostew
                            Discostew F @sys64738 last edited by

                            @sys64738 the resetting of the animation is more likely from assigning the frame when detecting the key press.

                            sys64738 1 Reply Last reply Reply Quote 1
                            • sys64738
                              sys64738 F @Discostew last edited by

                              @Discostew yeah that's it. Trying to figure out best way to stop it retriggering. Guess a Boolean switch will do for now

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

                                @Martin == vs = is the oldest trap in the book! Some compilers now warn you about this one

                                1 Reply Last reply Reply Quote 0
                                • Martin
                                  Martin Fuze Team last edited by

                                  I don’t know why my brain just assumes because it’s basic, it’s should be a single = and somehow magically know the difference!

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

                                    Was this ever resolved. Just got collisions working in my latest project and then turned off show collision boxes. And well here I am with same problem as Martin.

                                    Edit have loaded an empty map as above. And added

                                    
                                    for x = 0 to 10 loop
                                    collidemap(bubblesprite[x])
                                    Collide = detectspritecollision(subsprite,bubblesprite[x])
                                    

                                    And it works very occasionly for a bit then doesn't

                                    1 Reply Last reply Reply Quote 0
                                    • Martin
                                      Martin Fuze Team last edited by Martin

                                      I am told that it is resolved in the next patch that has been submitted for review.

                                      It works 100% of the time for me when using what you have done. I do also collide subsprite with the map as well however. Maybe try that?

                                      sys64738 1 Reply Last reply Reply Quote 1
                                      • sys64738
                                        sys64738 F @Martin last edited by

                                        @Martin oh brilliant that was the problem, I didn't collidemap the sub, so obvious in hindsight! thank you!

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