Just breaking stuff
This commit is contained in:
31
archive/dawntictactoe/components/TicTacToeTile.cpp
Normal file
31
archive/dawntictactoe/components/TicTacToeTile.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "TicTacToeTile.hpp"
|
||||
#include "scene/SceneItem.hpp"
|
||||
#include "game/DawnGame.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
TicTacToeTile::TicTacToeTile(SceneItem *item) :
|
||||
SceneItemComponent(item),
|
||||
tileState(TIC_TAC_TOE_EMPTY),
|
||||
hovered(false)
|
||||
{
|
||||
}
|
||||
|
||||
void TicTacToeTile::onStart() {
|
||||
auto cb = [&]{
|
||||
auto sprite = this->item->getComponent<TiledSprite>();
|
||||
if(this->hovered && tileState == TIC_TAC_TOE_EMPTY) {
|
||||
sprite->setTile(0x03);
|
||||
} else {
|
||||
sprite->setTile(tileState);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(cb, tileState);
|
||||
useEffect(cb, hovered)();
|
||||
}
|
Reference in New Issue
Block a user