| 418 | } |
| 419 | |
| 420 | bool TestCase::init() |
| 421 | { |
| 422 | if (Scene::init()) |
| 423 | { |
| 424 | // add title and subtitle |
| 425 | TTFConfig ttfConfig("fonts/arial.ttf", 26); |
| 426 | _titleLabel = Label::createWithTTF(ttfConfig, title()); |
| 427 | addChild(_titleLabel, 9999); |
| 428 | _titleLabel->setPosition(VisibleRect::center().x, VisibleRect::top().y - 30); |
| 429 | |
| 430 | ttfConfig.fontSize = 16; |
| 431 | _subtitleLabel = Label::createWithTTF(ttfConfig, subtitle()); |
| 432 | _subtitleLabel->setMaxLineWidth(VisibleRect::getVisibleRect().size.width); |
| 433 | addChild(_subtitleLabel, 9999); |
| 434 | _subtitleLabel->setPosition(VisibleRect::center().x, VisibleRect::top().y - 60); |
| 435 | |
| 436 | _priorTestItem = MenuItemImage::create(s_pathB1, s_pathB2, AX_CALLBACK_1(TestCase::priorTestCallback, this)); |
| 437 | _restartTestItem = |
| 438 | MenuItemImage::create(s_pathR1, s_pathR2, AX_CALLBACK_1(TestCase::restartTestCallback, this)); |
| 439 | _nextTestItem = MenuItemImage::create(s_pathF1, s_pathF2, AX_CALLBACK_1(TestCase::nextTestCallback, this)); |
| 440 | |
| 441 | ttfConfig.fontSize = 20; |
| 442 | auto backLabel = Label::createWithTTF(ttfConfig, "Back"); |
| 443 | auto backItem = MenuItemLabel::create(backLabel, AX_CALLBACK_1(TestCase::onBackCallback, this)); |
| 444 | |
| 445 | auto menu = Menu::create(_priorTestItem, _restartTestItem, _nextTestItem, backItem, nullptr); |
| 446 | |
| 447 | menu->setPosition(Vec2::ZERO); |
| 448 | _priorTestItem->setPosition(VisibleRect::center().x - _restartTestItem->getContentSize().width * 2, |
| 449 | VisibleRect::bottom().y + _restartTestItem->getContentSize().height / 2); |
| 450 | _restartTestItem->setPosition(VisibleRect::center().x, |
| 451 | VisibleRect::bottom().y + _restartTestItem->getContentSize().height / 2); |
| 452 | _nextTestItem->setPosition(VisibleRect::center().x + _restartTestItem->getContentSize().width * 2, |
| 453 | VisibleRect::bottom().y + _restartTestItem->getContentSize().height / 2); |
| 454 | backItem->setPosition(Vec2(VisibleRect::right().x - 50, VisibleRect::bottom().y + 25)); |
| 455 | |
| 456 | addChild(menu, 9999); |
| 457 | |
| 458 | return true; |
| 459 | } |
| 460 | |
| 461 | return false; |
| 462 | } |
| 463 | |
| 464 | void TestCase::onEnter() |
| 465 | { |
no test coverage detected