Hello,
I’m using cocos creator 3.7.0, but method hitTest of UITransform is seem not working.
Basically, I have this code:
- register event
this.node.on(NodeEventType.TOUCH_END, this._onTouchEnded, this, true);
- process touch end:
protected _onTouchEnded (event: EventTouch, captureListeners?: Node[]) {
// screen location
let screenPoint = event.getLocation() // {"x":779.2784423828125,"y":1581.3411254882812}
let uiPos = event.getUILocation() // {"x":519.5189615885416,"y":1054.2274169921875}
// Have to Sprite with transform.getBoundingBoxToWorld()
// 0 {"x":40,"y":968.699951171875,"width":283,"height":223}
// 1 {"x":348,"y":968.699951171875,"width":283,"height":223}
// Check collision by hitTest
if (transform.hitTest(screenPoint)) --> not working
// check collision by isHit
if (transform.isHit(uiPos)) --> it's working ( but it's deprecated since v3.5.0 )
Please tell me, what is wrong with hitTest method ? And how to fix it
Thank you