I have a ‘Squibble’ object that has two animations (Pink for player 1, and Green for player 2). Other than my base layer, I also have a ‘P1’ layer (where I’ve placed some Squibbles and set them to the Pink animation), and a ‘P2’ layer (where I’ve placed some more Squibbles and set them to the Green animation).
Both Pink (P1) and Green (P2) Squibbles are displayed on the same positions in the game. But only the P1 layer is visible to start with (and therefore only the Pink Squibbles). The P2 layer is hidden (and so are the Green Squibbles).
This is all well and good, except that when I click on a Pink Squibble to ‘activate’ it and make my move as player 1, the Green Squibble on the hidden P2 layer is also activated and moves as well.
How do I restrict interactions (mouse clicks/touches) to only the currently visible layer?
I thought to try this:
But that doesn’t work because it still applies to both the Pink and Green Squibble.
I can do this (which works):
But it’s convoluted. Is there a simpler way?