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.
    • Martin
      Martin Fuze Team last edited by

      Am wondering if I'm doing something completely wrong here since someone else must have seen this surely?!

      I've got enemy sprites and player sprites so I setup collision shapes for them all. I had the bounding box displayed so I could see it and sprite collisions were detected just fine. So for testing I figured when an enemy hit the player they would disappear. Now my problems start. If I set visibility to false either by the function or the parameter it doesn't work. the sprite is still displayed it just doesn't update any more.

      I figured it might be due to the collision shapes being displayed so I turned that off and now collision doesn't work at all. It does if I turn the box back on of course.

      Err, help?

      Obviously I can share my project tomorrow if it helps after I've had some sleep.

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

        Hi @Martin, I'd like to see your code if possible. I just tested out sprite collision and visibility and everything appears to be working on my end.

        With the following code, two swimmer sprites will collide in the middle of the screen after a short time. When they collide, the left sprite will become invisible. They'll no longer move since they'll continue colliding, but the swimmer's animation will show that the sprite is still being updated.

        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
        spr1.show_collision_shape = true
        
        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
        spr2.show_collision_shape = true
        
        setSpriteCamera(0, 0, 4)
        centerSpriteCamera(0, 0)
        
        while true loop
            
            clear(0, 0, 0, 0)
            
            result = collideSprites(spr1, spr2)
            if result.exists then
                spr2.visible = false
            endif
            
            updateSprites()
            drawSprites()
            update()
            
        repeat
        
        1 Reply Last reply Reply Quote 1
        • Martin
          Martin Fuze Team last edited by

          I’ve updated my shared code.

          Friend code: 5151-7991-7419

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

            I'm unable to add you, are you sure that's the correct friend code?

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

              retail and dev friend codes are not compatible

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

                What he said - I can only share my code with retail units. Sorry.

                PS: Jon and Colin are now added so hopefully one of them can look at it?

                PPS: Might want to be careful - I tried the code above and I'm guessing you're not Japanese :D

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

                  I'll have a look

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

                    Will, take a look at this


                    It is definitely the case that simply turning of the visible collision makes the collision work as intended.
                    I can't see any reason why this would be the case.

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

                      AND, there's a line further down that sets sprite.visible to false (also tried the function) so they shouldn't just be getting stuck in position, they should vanish (and I was rather hoping, not count for collision detection any more but that was the reason for the test).

                      Is there another way to effectively destroy the sprite once the enemy lives reaches 0? I may well be doing something perfectly dumb.

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

                        Sorry about that, I'll have to look into how to properly add you on my end. (@Jonboy I've sent you an email)

                        I've identified the issue- There is an issue once show_collision_shape is turned off. If the sprites are collided with a map first there is no issue, but when only colliding sprites the collision data won't get refreshed if show_collision_shape is off. (It refreshes it when it's on in order to accurately draw the collision shape.)
                        As a workaround for now please show collision shapes or add an empty map to your project and collide your sprites with it using collideMap.

                        As for the visibility issue I think I'd have to see your code for that one. Please hang tight until I can figure out what's up on my end with adding you.

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

                          Thanks Will - just upvoted your posts! Crazy that you need post approval :)

                          Strange you should mention collisionMaps - i'm just sat here browsing through the source for Super Mega Arena Blaster and had just arrived at "what's this here collision map then and how does it work"!! So I was just about to investigate collision maps.Because my enemies don't fire back (maybe later) I'm not telling it to collide sprites. So I was just about to go further down and see if you were doing anything any different to me when it comes to the player shots.

                          Right, will head down the collision map road then.

                          Very impressed with the structure of your code incidentally :+1:

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

                            Thanks! Since there's only one big code file, it's important to structure, comment, and use bookmarks efficiently for big projects. Using collideMap should work for now, even if the map is totally empty.

                            As for post approval- @MikeDX Do you think you could make me a mod?

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

                              Ah, I can do that - you'll still have to approve but at least you can do it yourself :)

                              The Map trick does indeed work - already done it. And I don't need to display the map for it to work.

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

                                Yup, it should work without drawing, only the collideMap call is needed.

                                This was working at some point earlier on, but got adjusted later in such a way that it no longer worked, and by then all my test projects were using maps!

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

                                  @Willpowered said in Sprites - Help!:

                                  As for post approval- @MikeDX Do you think you could make me a mod?

                                  I can but that won't help you, as everyone no matter what has to have 10 reputation before they don't need posts approved

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

                                    I've got 10 currently, so I think we're good! I can also help out with the approval queue.

                                    M 1 Reply Last reply Reply Quote 0
                                    • 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
                                            • First post
                                              Last post