用ai写的代码,我想通过点击屏幕就让小球落下但是不行

import { _decorator, Component, instantiate, Node, Prefab, resources, RigidBody2D } from ‘cc’;

const { ccclass, property } = _decorator;

//生成

@ccclass(‘shuiqqsc’)

export class shuiqqsc extends Component {

@property(Node)

spawnPoint: Node | null = null;

@property(Node)

fruitContainer: Node | null = null;

_currentFruit: Node | null = null;

@property(Node)

cmq:Node=null;

start() {

    this.generateNewFruit();

}

generateNewFruit() {

    const randomType = Math.floor(Math.random() * 3) + 1;

    resources.load(`prefabs/fruit${randomType}`, (err, prefab: Prefab) => {

        if (err) {

            console.error("失败", err); return;

        }

        const newFruit = instantiate(prefab);

        newFruit.setPosition(this.spawnPoint!.position);

        this.fruitContainer.addChild(newFruit);

        const rigidBody = newFruit.getComponent(RigidBody2D);

        if (rigidBody) rigidBody.enabled = false;

        this._currentFruit = newFruit;

        this.setupTouchControl(newFruit,this.cmq);

    });

}

setupTouchControl(fruitNode: Node,cmq:Node) {

    //fruitNode

    fruitNode.on(Node.EventType.TOUCH_START, () => {

        console.log("开始拖动");

    });

   

    fruitNode.on(Node.EventType.TOUCH_END, () => {

        const rigidBody =fruitNode.getComponent(RigidBody2D);

        if (rigidBody) rigidBody.enabled = true;

        this._currentFruit = null;

        this.scheduleOnce(() => this.generateNewFruit(), 1.0);

    })

}

}就是 setupTouchControl这里如果是fruitNode.on(Node.EventType.TOUCH_END, () => 也就是fruitNode在前面那么代码可以运行,但是如果是我创建的cmq,cmq.on(Node.EventType.TOUCH_END, () => 就不行,我只改了这里,cmq是空节点,添加了boxcollider2D组件,问了ai也找不到原因,为什么不行?版本3.8.7

你的cmq空节点,不会连UITransform组件都没有吧?:space_invader:
是要用UITransform组件,来决定点击范围的呀

还真是,我还以为是boxcollider2D组件控制呢,谢谢大佬.