Jump to content

Clicking through transparent pixels


rroylance
 Share

Recommended Posts

Hi,

 

I need to be able to click through the transparent pixels of my sprites, how would I go about that ? I recall this being mentioned when Masking was added but I advent heard anything since and can't seem to find any answers anywhere.

 

Using hitArea is not acceptable since the images are not simple polygons. I have used a method previously where I exported the alpha data of my textures as an array from Flash and then used the local coordinates of the touch to check the alpha array, but I would prefer to not have to do that again.

 

Thanks.

Link to comment
Share on other sites

Hi

The topic was discussed many time, i dont remember if it was on pixi thread.

 

It depends what do you need it for.

 

I encountered the same problem many times, and quickest way is to make hitArea as polygons, even complex polygons made for sprites are quicker in code than check transparency of pixels. 

 

There is a nice software for making polygons of sprites and i use it with all sprites, PhysicsEditor

 

Im new here and not an expert, but already love Pixi,

 

thx GoodBoy and community

Link to comment
Share on other sites

Hi

The topic was discussed many time, i dont remember if it was on pixi thread.

 

It depends what do you need it for.

 

I encountered the same problem many times, and quickest way is to make hitArea as polygons, even complex polygons made for sprites are quicker in code than check transparency of pixels. 

 

There is a nice software for making polygons of sprites and i use it with all sprites, PhysicsEditor

 

Im new here and not an expert, but already love Pixi,

 

thx GoodBoy and community

 

Thanks for the input, that tool/ a free alternative I found called Box2d-editor should work perfectly. I never even considered the possibility of a tool to define the sprites.

 

EDIT: I found that someone had implemented a transparency based hit area, and for my purposes (only needed for clicking/tapping) this works great. It can be found @ https://github.com/peci1/pixi.js/blob/415a86138e8b224ccce8fce5e974be439403a364/src/pixi/extras/TransparencyHitArea.js

Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...