Game Development Community

Mouse clicks based on sprite alpha

by Alexey Stashin · in Torque Game Builder · 12/05/2008 (1:30 pm) · 7 replies

Hello all,

How to get pixel alpha value of sprite to prevent clicks on transparent regions?
Or may be there is other way exist?

Thanks

#1
12/05/2008 (2:39 pm)
Have you edited the collision poly? That's the only way I know of, without changing the engine code. It's not perfect, but better than a square.
#2
12/06/2008 (1:24 am)
Thanks fo reply, but collision poly is not solution, I need to manage 100+ different images per scene and creating collision polys for each of them is nightmare.
As I understand, direct pixel access impossible without source modification. Does source code has ways to make it possible?
#3
12/06/2008 (7:42 am)
Obviously almost anything is possible when you have the source code. I'll be honest though, the main point of TGB is to abstract you away from that. The feature you require depends on that.

TGB will tell you what object has been picked (selected) and can provide you with the information for you to calculate what local-space coordinate of the object has been click. You can use this information to make local queries to the object.

In your case you want to interrogate alpha-texel info. It does sound like you need to try an alternative method, perhaps calculating these maps offline. You can then perform the look-up when you know where on the object you've clicked.

It is possible though, with the source, to expose a deeper query for image information. You'd have to first check what image-map the object uses as well as what frame. You can then go to the image-map and query the appropriate texel.

Don't forget though that you don't go to a sprite to ask it about the texels (image info) because it doesn't own it, the image-maps do.

Hope this helps,

Melv.
#4
12/06/2008 (11:58 am)
Great thanks, Melv. It is all I need to know before buying TGB Pro licence.
#5
12/21/2008 (5:44 am)
Hey Alexey Stashin did you manage to succeed on that quest? I'm having the same problem as you.

Thanks
#6
12/24/2008 (12:35 pm)
No, Gilberto, I don't have TGB Pro license and engine sources. I'm just choosing engine now for my casual projects and I didn't work with TGB closely yet.
If you will found solution, please write link here. Thanks
#7
02/03/2009 (6:28 am)
I've changed the source to manage this.
Check here -> http://www.garagegames.com/community/forums/viewthread/81610