Page 1 of 1

Mouse Button Down on the transparent area

PostPosted: Wed Jan 05, 2011 8:50 am
by saikspaik
If you add an actor with a sprite with transparent areas, the Mouse Button Down will work only on the opaque areas.
How to make that - Mouse Button Down work all over the sprite?

Re: Mouse Button Down on the transparent area

PostPosted: Wed Jan 05, 2011 9:21 am
by schnellboot
fill the gaps with filled regions and add them the same event on mouse button down

Re: Mouse Button Down on the transparent area

PostPosted: Wed Jan 05, 2011 8:19 pm
by saikspaik
But what if my actor is moves, move filled region with it? And if actors more than one?
I mean, maybe GM have some sort of option to use bounding box, or add a mask that can be clicked instead of actor sprite? It would be very helpful.

Re: Mouse Button Down on the transparent area

PostPosted: Wed Jan 05, 2011 9:03 pm
by skydereign
The only problem with using a filled region, is if you animation changes to something smaller, the filled region will stay the same size as before. So, you would want to create with dimensions equal to the actor's biggest animation. You can however implement a smaller box, when given a bigger box, by using xmouse/ymouse to determine where the click happened, but the filled region will always have to be the larger size.

To make it follow the actor, just make the filled region's parent, the actor you want to click. If your actor will always be clickable, I would have it create the filled region on it's create actor event.

Re: Mouse Button Down on the transparent area

PostPosted: Thu Jan 06, 2011 2:36 pm
by 157pl
show us the actor so we can tell you where to put the filled regions.
if its rectangular you can put it over the whole actor

Re: Mouse Button Down on the transparent area

PostPosted: Thu Jan 06, 2011 7:01 pm
by saikspaik
Here is my sprite
Image
Mouse Button Down will work only when I click on white pixels (in this case)

But I want that Mouse Button Down work when I click inside of bounding box (I pictured it for illustration)
Image

Re: Mouse Button Down on the transparent area

PostPosted: Thu Jan 06, 2011 7:38 pm
by sonicfire
best is to use a transparent PNG, and then add your "clickable" area as a second layer with 99% transparency (all this in your fav. graphics program).
So you won´t see that area in the game but it is "clickable" - this is what i do all the time :-) Hope it helps!

Re: Mouse Button Down on the transparent area

PostPosted: Fri Jan 28, 2011 7:02 pm
by saikspaik
Okay, I tried both methods for solving problems with a transparent area, and the sources of my work below.
Method with the Filled Region works well for one actor, but if actors two or more, some of the problems begin.
Method with 99% transparent PNG layer works well, and I think this is the best variant, at least for now.
But anyway, GE needs an option where you can choose how to detect mouse click on the actor (bounding box, or precise check).

Hope you understand my english. :)
FilledRegionTest.zip
Variant with Filled Region
(65.51 KiB) Downloaded 77 times

PngLayerTest.zip
Variant with 99% transparent png layer
(66.74 KiB) Downloaded 88 times

Re: Mouse Button Down on the transparent area

PostPosted: Sun Jan 30, 2011 9:27 pm
by sonicfire
saikspaik wrote:Okay, I tried both methods for solving problems with a transparent area, and the sources of my work below.
Method with the Filled Region works well for one actor, but if actors two or more, some of the problems begin.
Method with 99% transparent PNG layer works well, and I think this is the best variant, at least for now.
But anyway, GE needs an option where you can choose how to detect mouse click on the actor (bounding box, or precise check).

Hope you understand my english. :)
FilledRegionTest.zip

PngLayerTest.zip


You can always use an activation region and set it so the size of your sprite and let this check for events/collisions! :) (just make it a parent of your actor).

The other thing is, if you have e.g. a PNG file with alpha (transparency) and if you want to have bounding box collision checking, i always create another layer in photoshop, then make it completle black and set alpha to 1%. this way you cannot really see it but it´s there and gets considered for collision checking.

i´m totally fine with GE´s pixelperfect collision system! i dont like the bounding box stuff :D (just my opinion).

Re: Mouse Button Down on the transparent area

PostPosted: Sun Jan 30, 2011 11:51 pm
by saikspaik
The other thing is, if you have e.g. a PNG file with alpha (transparency) and if you want to have bounding box collision checking, i always create another layer in photoshop, then make it completle black and set alpha to 1%. this way you cannot really see it but it´s there and gets considered for collision checking.


So far, this is the best way. And by the way, about the png with alpha you've said in this same topic, remember?:)
I just thanks to your advice solve my problem, so thank you:)

i´m totally fine with GE´s pixelperfect collision system! i dont like the bounding box stuff (just my opinion).

The bounding box does not necessarily use everybody at once. ;) But if such an option was, it would only get better.

Re: Mouse Button Down on the transparent area

PostPosted: Mon Jan 31, 2011 2:01 am
by sonicfire
saikspaik wrote:So far, this is the best way. And by the way, about the png with alpha you've said in this same topic, remember?:)
I just thanks to your advice solve my problem, so thank you:)


Doh! :oops: I´m getting old... :lol: