-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextBox.cpp
47 lines (40 loc) · 1.83 KB
/
textBox.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "textBox.h"
TextBox::TextBox(std::string s, sf::Font &f)
{
setFont(f);
m_index = 0;
maxTime = 0.05;
m_timer = 0.0;
m_completeString = s;
}
void TextBox::setSentence(std::string &s)
{
m_index = 0;
m_timer = 0.0;
m_completeString = s;
}
void TextBox::update(float dt)
{
m_timer += dt;
if(m_timer > maxTime && m_index < m_completeString.size()){
setString(getString()+m_completeString[m_index]);
++m_index;
m_timer = 0;
//std::cout << ": ( " << m_completeString[m_index-1] << std::endl;
}
else if(m_timer >= 3 && m_index >= m_completeString.size() && m_completeString.size() > 0){
// std::cout << "DELETEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" << std::endl;
setString("");
m_completeString = "";
}
else {
/* std::cout << m_completeString << " nd " << std::string(getString()) <<"VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" << std::endl;
std::cout << m_timer <<"VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" << std::endl;
std::cout << maxTime << "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" << std::endl;
std::cout << m_index << "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" << std::endl;
std::cout << "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" << std::endl;
std::cout << "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" << std::endl;
std::cout << "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" << std::endl;
*/
}
}