2

I need to add a translucent guide layer above my UI, details are as follows:

  1. there is one (or more) area (which I suggest the user to click) of the layer, and it's totally transparent and transmit touches to the UI below.
  2. At the same time, the rest part of the layer, which is translucent, swallows touches.

"Now Click B"

I use a LayerColor clipped by ClippingNode to implement the guide layer, and I have a EventListenerTouchOneByOne (setSwallowTouches(true)) to detect touch, and then, in

bool touchBegan(cocos2d::Touch *touch, cocos2d::Event *event) {
    // return (whether touch point belongs to translucent area).
}

So is there any way to judge whether a point belongs to the clipped area? Thanks.

p.s. Since the shape of clipped area is irregular, the way by checking whether the boundingBox of the stencil contains the touch point may not be acceptable.

p.p.s I've tried the way of judging pixel value of my LayerColor following methods such as Getting RGBA value of a pixel in a CCSprite, but failed to get values, someone says that the methods applies no more for cocos2d-x 3.x? Besides, I wonder will the pixel value of the LayerColor really change after being clipped?

Thanks again :D

Community
  • 1
  • 1
weiwen
  • 446
  • 6
  • 16

0 Answers0