I need a bit of help again.
I have added in sprites to my game that are used as clickable menus, and when I click out of the menu, the menu closes. Awesome.
My problem is that the clickable area for the menu is larger than the menu itself. As you can see here:
Other than editing the image itself to give it a smaller canvas size, is there a way to change the clickable area of a sprite from within GDevelop? Thanks!
Double-click on the “menu” object in the Object’s editor pane to open the “Edit the sprite object” window. Then click on the icon that is diagonal lines in a square (near top of the window). The current hitbox for that object should now be shown.
In the Collision masks pane at the bottom of the window, click on the word default.
Then click on the second icon from the left (green cross with blue line and red dot) This should make a rectangle (with blue dots at the corner) appear over the menu object. You can now drag the blue dots of the hitbox with the mouse to make the hitbox smaller.
If you want to keep it as a rectangle it might be easier to just change the X and Y numbers corresponding to the four corners, rather than dragging.
I updated the hitbox with what I want it to be, but the game still registers the “menu” as larger than it really is.
Here is my code (if that is my issue)
Here is how I set up the hitbox:
However, the actual game still thinks the object is the same as the first picture I posted. Not sure what I’m doing wrong here…
It seems I got it working.
I couldn’t figure it out within GDevelop, so I edited the canvas to be the size of the image (in a picture editor).
When I added the sprite back in, it worked perfectly.
Thinking about it, the hitbox size probably only applies to object-with-object collision detection. Mouse-clicks may always use the whole sprite.