6
« on: February 08, 2012, 06:40:53 pm »
Hi i'm making a breakout clone and i'm trying to implement the score. I have it all working, however when i draw the text it doesn't draw it in the same place but instead draws it as if i was holding a number key down i.e
"000000000000000000000000000000000000" across the screen. I don't know why it's doing this any help would be apreciated Thanks.
heres the .cpp
#include "scoreboard.h"
scoreboard::scoreboard(){}
void scoreboard::init()
{
scoreboardIMG.LoadFromFile("Maze/assets/scoreboard.png");
scoreB = sf::Sprite (scoreboardIMG);
scoreB.SetPosition(800,0);
playerScore = 0;
Cheeseburger.LoadFromFile("Maze/assets/andyb.ttf");
scoreText.SetFont(Cheeseburger);
scoreText.SetSize(15.f);
scoreText.SetColor(sf::Color(0,0,255));
}
void scoreboard::draw(sf::RenderWindow& win)
{
win.Draw(scoreB);
win.Draw(scoreText);
}
void scoreboard::getScore(ball& ball)
{
playerScore = ball.getDestroyed() * 50;
pScore << playerScore;
scoreText.SetText(pScore.str());
scoreText.SetPosition(0.f, 320.f);
scoreText.Move(0.f,0.f);
}
and the
header
#ifndef SCOREBOARD_H
#define SCOREBOARD_H
#include<SFML\Graphics.hpp>
#include<sstream>
#include "ball.h"
class scoreboard
{
public:
scoreboard();
void init();
void draw(sf::RenderWindow&);
void getScore(ball&);
protected:
sf::Image scoreboardIMG;
sf::Sprite scoreB;
int playerScore;
sf::String scoreText;
sf::Font Cheeseburger;
std::ostringstream pScore;
};
#endif