- Notifications
You must be signed in to change notification settings - Fork 135
TicTacToe demo cocos2dx functionality #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Class and resource files required for cocos2dx
database/testapp/src/common_main.cc Outdated
| ||
#include <algorithm> | ||
#include <ctime> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're not really touching this file, can you just revert this change completely?
| ||
const int kNumberOfTiles = 9; | ||
const int kMaxMovesPerPlayer = 1 + kNumberOfTiles / 2; | ||
const int kTilesX = std::sqrt(kNumberOfTiles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do this the other way:
kTilesX = 3
kTilesY = 3
kNumberOfTiles = kTilesX * kTilesY;
| ||
USING_NS_CC; | ||
| ||
const int kNumberOfTiles = 9; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make all of these static.
const double kTileWidth = (kScreenWidth / kTilesX); | ||
const double kTileHeight = (kScreenHeight / kTilesY); | ||
const int kNumberOfPlayers = 2; | ||
std::array<std::string, kNumberOfPlayers> kMoveImageFileNames = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't have std::strings as global variables according to the C++ style guide.
https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables
strings do dynamic allocation and then delete on destruction, which is against the style guide rules.
Instead either use const char* here, or make it a string* and initialize the value at startup.
class AppDelegate : private cocos2d::Application { | ||
public: | ||
AppDelegate(); | ||
virtual ~AppDelegate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of virtual, use override.
// kScreenWidth = Director::getInstance()->getWinSize().width; auto | ||
// kScreenHeight = Director::getInstance()->getWinSize().height; | ||
| ||
auto board_sprite = Sprite::create("tic_tac_toe_board.png"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put "tic_tac_toe_board.png" in a constant
board_sprite->setAnchorPoint(Vec2(0.0, 0.0)); | ||
| ||
auto touchListener = EventListenerTouchOneByOne::create(); | ||
touchListener->onTouchBegan = [=](Touch* touch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://google.github.io/styleguide/cppguide.html#Lambda_expressions
Prefer explicit captures when the lambda will escape the current scope.
Only capture the variables you need in the lambda.
No description provided.