SFML и C++ Уроки \ Разработка игр › Форумы › SFML Начало работы (подключение и настройка) › не вижу изменения значений в реальном времени › Ответ в теме: не вижу изменения значений в реальном времени
Как использовать префикс L”…” в такой ситуации?
MyGame.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#include "stdafx.h" #include "Text.h" int main () { RenderWindow window(VideoMode(1024, 768), "MyGame"); float GameTime; Clock clock; CText gametime("Время Игры: ", 380, 10); while (window.isOpen()) { Event mainEvent; while (window.pollEvent(mainEvent)) { if (mainEvent.type == Event::Closed) window.close(); } GameTime = clock.getElapsedTime().asMicroseconds(); clock.restart(); GameTime = GameTime / 800; window.clear(); window.draw(gametime.GetText()); window.display(); } return 0; } |
Text.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include "Text.h" CText::CText(string name, int x, int y) { font.loadFromFile("Tahoma.ttf"); text.setFont(font); text.setString(name); text.setPosition(x, y); text.setColor(Color::Red); text.setStyle(Text::Bold); } CText::~CText(void) { } Text CText::GetText() { return text; } |
Text.h
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#pragma once #include "stdafx.h" class CText { public: CText(string name, int x, int y); ~CText(void); Text GetText(); private: Font font; Text text; }; |
stdafx.h
C++
1 2 3 4 5 6 7 |
#pragma once #include <SFML/Graphics.hpp> #include <iostream> using namespace sf; using namespace std; |