coco3.4 按钮挂相机后,不能点击!!!!

我用lua继承layer为touchlayer,然后,监听这个层的点击事件,这个监听正常,但是,我往这个层加了一个按钮

氀漀挀愀氀 button_callback = function(sender,eventType)
瀀爀椀渀琀(“ffffffffffffffffffffffffffffffff”)
end

local button = ccui.Button:create(“btns/shotbtn.png”,“btns/shotpressbtn.png”)
button:move(display.center)
button:setGlobalZOrder(10)
button:addTouchEventListener(button_callback)
self:addChild(button, 4)

然后挂到相机上
camera:lookAt(cc.vec3(hero_pos.x, hero_pos.y, 50), cc.vec3(0.0, 0.0, 1.0))

local set_camera = function(scene, contrl_layer)
camera = cc.Camera:createPerspective(40.0, size.width/size.height, 1.0, 4000)
camera:retain()
camera:setGlobalZOrder(10)
camera:addTo(scene)
contrl_layer:addTo(camera)

contrl_layer:setPositionZ(-cc.Director:getInstance():getZEye())
contrl_layer:ignoreAnchorPointForPosition(false)
contrl_layer:setGlobalZOrder(3000)
end

怎么点按钮都没反应!!

不加相机,按钮是正常可以点击的吧?可能还是多相机的问题,我试一下。

不把按钮挂相机,正常,一挂就跪了

求解决啊~~~求指导!

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    auto visibleSize = Director::getInstance()->getVisibleSize();
    auto origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        CC_CALLBACK_1(HelloWorld::menuCloseCallback,this));
    
    closeItem->setPosition(origin + Vec2(visibleSize) - Vec2(closeItem->getContentSize() / 2));

    // create menu, it's an autorelease object
    auto menu = Menu::create(closeItem, nullptr);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);
    
    /////////////////////////////
    // 3. add your codes below...
    
    // add "HelloWorld" splash screen"
    auto sprite = Sprite::create("HelloWorld.png");

    // position the sprite on the center of the screen
    sprite->setPosition(Vec2(visibleSize / 2) + origin);

    // add the sprite as a child to this layer
    this->addChild(sprite);
    
    //
    auto camera1 = Camera::create();
    camera1->setCameraFlag(cocos2d::CameraFlag::USER1);
    this->addChild(camera1);
    
    auto camera2 = Camera::create();
    camera2->setCameraFlag(cocos2d::CameraFlag::USER2);
    this->addChild(camera2);
    
    // Create the button
    cocos2d::ui::Button* button = cocos2d::ui::Button::create("CloseNormal.png",
                                                              "CloseSelected.png");
    // open scale9 render
    button->setPosition(Vec2(visibleSize.width / 2.0f, visibleSize.height / 2.0f));
    button->addTouchEventListener(CC_CALLBACK_2(HelloWorld::touchEvent, this));
    this->addChild(button);
    
    return true;
}

void HelloWorld::touchEvent(Ref *sender, cocos2d::ui::Widget::TouchEventType controlEvent)
{
    CCLOG("1111");
}
```


在C++里面加两个相机是正常的

为什么不用这个函数创建相机
cc.Camera:createPerspective(40.0, size.width/size.height, 1.0, 4000)

cc.Camera:createPerspective(40.0, size.width/size.height, 1.0, 4000)
再这样
camera:setCameraFlag(cc.CameraFlag.USER1)

这样设置,前面建立的裁剪区间没用了
camera:lookAt(cc.vec3(hero_pos.x, hero_pos.y, 50), cc.vec3(0.0, 1.0, 0.0))也变废了

camera:lookAt(cc.vec3(hero_pos.x, hero_pos.y, 50), cc.vec3(0.0, 0.0, 1.0)) 让Z轴朝上没用了!

我也遇到这个问题 把csb文件加载到layer中 然后把UILayer挂到摄像机上 上面的按钮就不响应了 不知您解决问题了么
大牛们帮忙给支个招