| 463 | } |
| 464 | |
| 465 | void Scene3DTestScene::createUI() |
| 466 | { |
| 467 | _ui = Layer::create(); |
| 468 | |
| 469 | // first, add menu to ui |
| 470 | // create player button |
| 471 | auto showPlayerDlgItem = MenuItemImage::create("Images/Pea.png", "Images/Pea.png", [this](Object* sender) { |
| 472 | this->_playerDlg->setVisible(!this->_playerDlg->isVisible()); |
| 473 | }); |
| 474 | showPlayerDlgItem->setName("showPlayerDlgItem"); |
| 475 | showPlayerDlgItem->setPosition(VisibleRect::left().x + 30, VisibleRect::top().y - 30); |
| 476 | |
| 477 | // create description button |
| 478 | TTFConfig ttfConfig("fonts/arial.ttf", 20); |
| 479 | auto descItem = MenuItemLabel::create(Label::createWithTTF(ttfConfig, "Description"), [this](Object* sender) { |
| 480 | if (this->_descDlg->isVisible()) |
| 481 | { |
| 482 | // hide descDlg |
| 483 | _descDlg->setVisible(false); |
| 484 | } |
| 485 | else |
| 486 | { |
| 487 | // animate show descDlg |
| 488 | _descDlg->setVisible(true); |
| 489 | _descDlg->setScale(0); |
| 490 | _descDlg->runAction(ScaleTo::create(2, 1.0)); |
| 491 | } |
| 492 | }); |
| 493 | descItem->setName("descItem"); |
| 494 | descItem->setPosition(Vec2(VisibleRect::right().x - 50, VisibleRect::top().y - 25)); |
| 495 | |
| 496 | auto menu = Menu::create(showPlayerDlgItem, descItem, nullptr); |
| 497 | menu->setPosition(Vec2::ZERO); |
| 498 | _ui->addChild(menu); |
| 499 | |
| 500 | auto audioCheckbox = ui::CheckBox::create("cocosui/check_box_normal.png", "cocosui/check_box_normal_press.png", |
| 501 | "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", |
| 502 | "cocosui/check_box_active_disable.png"); |
| 503 | audioCheckbox->setSelected(true); |
| 504 | audioCheckbox->setName("Audio"); |
| 505 | audioCheckbox->setAnchorPoint(Vec2::ANCHOR_BOTTOM_RIGHT); |
| 506 | audioCheckbox->setScale(0.8f); |
| 507 | audioCheckbox->addEventListener( |
| 508 | [this](ax::Object* sender, ax::ui::CheckBox::EventType eventType) { |
| 509 | if (eventType == ui::CheckBox::EventType::UNSELECTED) |
| 510 | { |
| 511 | AudioEngine::pause(_audioId); |
| 512 | } |
| 513 | else |
| 514 | { |
| 515 | AudioEngine::resume(_audioId); |
| 516 | } |
| 517 | }); |
| 518 | auto label = ui::Text::create(); |
| 519 | label->setString("Positional Audio"); |
| 520 | label->setAnchorPoint(Vec2(0, 0)); |
| 521 | label->setPositionX(audioCheckbox->getContentSize().width); |
| 522 | audioCheckbox->addChild(label); |
nothing calls this directly
no test coverage detected