Topic was automatically imported from the old Question2Answer platform.
Asked By
RetroDan007
Old Version
Published before Godot 3 was released.
Hello everyone.
I have this scene:
In in which I have a TextureButton, and upload an image of 200 x 200.
It is a star who just want to work within the entrella.
Using a CollishionShape2D.
And change to another scene: res //: Scenes / NameScene.tscn
A collision shape is not going to give you the behavior you’re looking for here.
You can, however, set the Click Mask of the TextureButton.
To make a click mask:
Create a texture that is identical to your button’s texture.
Any pixel you want to be ‘clickable’ should be white, while all other pixels are black.
Save this mask image in .pbm format.
Load that .pbm file as your Click Mask on the TextureButton
I have had problems using this, untill people on the irc told me to replace the black with alpha (on the png before importing). It worked from then on.
So just to recap, I used alpha for black values, and white wher I wanted the texture to be clickable.
Create a black star with transparent background, save as PNG:
Import the star as a bit mask:
A: Select to the black star file.
B: Set the target path to save the bit mask into.
C: Click Import. Godot will create a .PBM file of the star in the target path.
Assign the newly created .PBM file to the TextureButton’s Click Mask property: