Hey guys, i'm writing a little snake game to get acquainted with SFML 2.1, Thor, and some of the new c++11 features.
I'm having some trouble getting a thor::CallbackTimer to fire. The timer is counting down, being updated every frame, and the connection is valid, but the callbacks aren't being called when the timer expires.
This is how i'm connecting the callback. In the documentation of Thor it looked like it needed a thor::CallbackTimer parameter, but that didn't solve the problem.
mSpecialFoodTimer.connect(std::bind(&Snake::setUpSpecialFood, this));
This is very similar to what is in the examples for Thor, yet it doesn't fire either.
mSpecialFoodTimer.connect(std::bind(&sf::RectangleShape::setFillColor, &gameBoard, sf::Color::Blue));
I also tried it by just putting a lambda statement in there, same behavior. (i'm not sure if this would work in the first place, no compile errors though.)
connect = mSpecialFoodTimer.connect([this] (thor::CallbackTimer & timer) -> void
{
std::cout << "food timer called\n";
food new_food;
sf::Vector2i pos = this->getOpenPosition();
new_food.mapPos = pos;
new_food.type = (thor::random(0,1) == 0 ? FOOD_TYPE::GRAPE : FOOD_TYPE::ORANGE);
mFood.push_back(new_food);
});
Any help would be appreciated !