怎么用代码写一个 cocostudio Button出来

2025-05-04 15:48:25
推荐回答(1个)
回答1:

您好,请参考testcpp中的GUI示例,
button创建方法:

// Create the button
UIButton* button = UIButton::create();
button->setTouchEnabled(true);
button->loadTextures("cocosgui/animationbuttonnormal.png", "cocosgui/animationbuttonpressed.png", "");
button->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent));
m_pUiLayer->addWidget(button);