do On Touched for semi-transpartent button

Get help using Construct 2

Post » Fri Sep 21, 2012 3:27 pm

All the buttons for the game are semi-transparent, so they show part of the background through (i.e. alpha of 127). The text on the button has alpha of 255 though so its nice to read.

The problem is the on touch event for this button does not fire unless you click on the txt of the button, which is very difficult and unintuitive.

Any ideas for a fix?

I could drop all the touch handling, and write my own, but this is a huge pain, especially as I am sliding the text in and out (for info and settings)using the bullet behavior, and mapping the mouse position to the button positions and scaled sizes is tricky and tedious.

Thanks for your help and ideas!
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Fri Sep 21, 2012 3:42 pm

Are you talking about button objects or sprites acting as buttons?
AFIAK there's no way to set opacity on real button objects but I might be wrong.
If you are talking about sprites, the on touched event works in my game even with zero opacity. Try to control the collision mask.Knifegrinder2012-09-21 15:42:27
B
11
S
3
Posts: 224
Reputation: 2,028

Post » Fri Sep 21, 2012 3:59 pm

Sorry, I'm talking about a sprite which is acting as a button.   Nothing I click on except the solid text part of the button will register (ill create a capx shortly).
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Fri Sep 21, 2012 4:03 pm

can you share a capx? For me it sounds like that you put the on touch action on the text and not the image.
B
42
S
9
G
6
Posts: 437
Reputation: 5,626

Post » Fri Sep 21, 2012 4:11 pm

@nutmix You could create a solid colored image sprite the same size as your button, place it under your button, set it to invisible in your properties window, and give it your on touch event.
B
50
S
11
G
8
Posts: 479
Reputation: 9,911

Post » Sat Sep 22, 2012 3:36 pm

Here is the capx for the non working touch sprites:

https://www.dropbox.com/s/bmjya8iefnjtjmk/alphaButtonSpriteFail.capx

It only works if you click on the + or - pixels of the sprite which have the alpha channel set to 255.

Any thoughts to why its not working appreciated.

Winks idea of using a hidden object underneath is probably the only workaround, but as I move this panel left and right with swipe, I can never get the objects to light up properly after (and you cant mix text and sprites in the same family). I will try pinning the invisible button to the non working button.

Its a bit ironic that an invisible object will catch touch events, but a visible one wont.
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Sat Sep 22, 2012 4:15 pm

Manually adjust collision polygons in an image editor so that they cover desired area of the buttons.

At the moment it rings only non transparent area:

Kastas2012-09-22 21:31:14
B
79
S
32
G
23
Posts: 119
Reputation: 14,937

Post » Sat Sep 22, 2012 10:54 pm

Wow, brilliant! Problem solved.

I have never used collision polygons - all my games are casino type games.

Thanks again guys - great help and advice!
B
15
S
5
G
2
Posts: 357
Reputation: 3,691


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 23 guests