Transparent areas for buttons

Started by Digital Mosaic Games, Sun 10/03/2019 19:04:49

Previous topic - Next topic

Digital Mosaic Games

Hey guys,

I'd like to have a specific transparent area for a button which shouldn't be clickable(pink area)...


But at the moment I can only have a rectangle as clickable area for the button.


Is there a way to make the pink/transparent area not clickable?

Thanks!

Khris

You can make that area not react to a click by doing a coordinate check.

Code: ags
  int x = mouse.x - (control.OwningGUI.X + control.X);
  int y = mouse.y - (control.OwningGUI.Y + control.Y);


This gives you click coordinates inside the button rectangle. You can now either

a) use  if (x + y < 20) return;  for a basic check against the 45° edge

b) grab the pixel's color from the sprite using a DrawingSurface and GetPixel() and compare it to COLOR_TRANSPARENT

Digital Mosaic Games

Hi Khris, thank you very much for answering!
I tried the method (a) as you suggest and it is working fine. However how can I code the same thing regarding a button top right, down left and down right?
I mean these buttons...

Khris

Sure, all that changes is the expression in the check.

The top right one: y > x - 4
Bottom left: y < x + 6
Bottom right: y < 32 - x

Digital Mosaic Games

Thank you very much for your help it was greatly appreciated!

SMF spam blocked by CleanTalk