[Resolved] Hit test bug in ScrollView/PageView/etc in case of multiple instances on a screen

Cocos2d-x v3.7 Issue

Strange hit testing appears when you add some scrollviews on a scene: more you do - more offset in hit test you get. As a result, we have an undefined touch area(usually behind some other nearby scrollview) which controls our target scrollview. Here’s a case log (I tried to tap at the same point in both cases). Presented _touchBeganPosition is being calculated for the same PageView instance in both cases.

  • Case: 1 PageView instance

Printing description of touch->_point:

(cocos2d::Vec2) _point = (x = 45.6338043, y = 279.577454)

(cocos2d::Vec2) _touchBeganPosition = (x = 45.9532356, y = 40.6190796)
  • Case: 3 PageView instances

Printing description of touch->_point:

(cocos2d::Vec2) _point = (x = 46.4788742, y = 278.309845)

(cocos2d::Vec2) _touchBeganPosition = (x = -109.203339, y = 11.0960379)

So, touch->getLocation() ( Director::getInstance()->convertToGL(_point) ) does smth unexpected.

Gonna try a newer 3.8 version. Hope it has a fix in a box.

EDT: Cocos2dx 3.8 version doesn’t provide any fix, behavior is still the same.

Seems Tomxey had completely same case and solved it.
Be careful in your own drawing funcitons with matrix stack. :smile: