I’m working on my top-down grid-based game where little balls move from square to square. If they hit a little round “bumper” they turn left or right (or reverse if they hit two at once). That was all working perfectly when the bumpers are placed on screen beforehand and they only had one animation. But I need a “dormant” state that the balls will ignore, as well as an “active” state,.
So I added a “dormant” animation, which has no hit box, and an “active” animation, which does have a hit area. Each animation has only 1 frame. If I set all the bumpers to the “active” animation when the game starts, clicking on a bumper properly changes it to its “dormant” animation and the balls ignore it. But if I click a “dormant” bumper it does NOT change to the “active” animation. Instead the game freezes! And I need to start the game with all bumpers dormant.
Anyone know what’s going on? I can post more code if necessary. Thanks!!!
I’m nont sure, but you could try:
cursor is on bumper
-first sub condition
-mouse is down set animation…
-second sub condition
-mouse is down (reverse) set animation…
You are checking if “cursor/touch is on bumper” but bumper has no hitbox, that’s probably what freezes the game.
Yes, adding a hitbox to the dormant animation stopped the game from freezing, thanks! I just had to then add an extra condition so the balls would only deflect if the bumper was on the active animation.
I should have thought of the hitbox thing but the fact that the game froze entirely threw me. It seems like this behavior could be called a bug. I could see GDev doing NOTHING if there’s no hitbox, but I wouldn’t think it should gag, because the cursor is “on” the object (its x and y coordinates are inside the boundary of the sprite).
What did you do to remove the hitbox?
I tried but couldn’t reproduce the freeze.
If you’re able to reproduce the issue in an empty project, we’ll file a bug report.
I went to EDIT HITBOXES and clicked the “USE A CUSTOM COLLISION MASK”. Then I simply closed the dialog box without clicking the + button and so didn’t add any hitbox area.
hmm… do bumpers have a behavior?
Yes, when “active” they deflect the ball 90° left or right, depending on which side of the ball they are on. They have no effect if they are on the “dormant” animation.
If you want more info, see the annotated screen shot in my first posting above. Dotted lines show how the black balls are deflected by the orange bumpers. (When hitting two bumpers they are supposed to reverse. This was working up until I fixed the clicking problem; now they go right through double bumpers…sigh.)
I meant an object behavior, in the object properties (third screenshot).