25 lines
646 B
C++
25 lines
646 B
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "TicTacToeScoreboard.hpp"
|
|
|
|
using namespace Dawn;
|
|
|
|
TicTacToeScoreboard::TicTacToeScoreboard(SceneItem *item) :
|
|
SceneItemComponent(item)
|
|
{
|
|
|
|
}
|
|
|
|
void TicTacToeScoreboard::onStart() {
|
|
auto game = getScene()->findComponent<TicTacToeGame>();
|
|
assertNotNull(game);
|
|
|
|
useEffect([&]{
|
|
auto label = item->getComponent<UILabel>();
|
|
assertNotNull(label);
|
|
label->text = std::to_string(game->scoreNought) + " - " + std::to_string(game->scoreCross);
|
|
}, { &game->scoreCross, &game->scoreNought })();
|
|
} |