revisat intro.cpp, path_sprite i writer.cpp
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
|
||||
#include "text.h" // Para Text
|
||||
|
||||
// Actualiza el objeto
|
||||
// Actualiza el objeto (delta_time en ms)
|
||||
void Writer::update(float delta_time) {
|
||||
if (enabled_) {
|
||||
if (!completed_) {
|
||||
// No completado
|
||||
writing_timer_ += delta_time;
|
||||
if (writing_timer_ >= speed_ms_) {
|
||||
if (writing_timer_ >= speed_interval_) {
|
||||
index_++;
|
||||
writing_timer_ = 0.0f;
|
||||
}
|
||||
@@ -24,6 +24,12 @@ void Writer::update(float delta_time) {
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el objeto (delta_time en segundos)
|
||||
void Writer::updateS(float delta_time) {
|
||||
// Convierte segundos a milisegundos y usa la lógica normal
|
||||
update(delta_time * 1000.0f);
|
||||
}
|
||||
|
||||
// Dibuja el objeto en pantalla
|
||||
void Writer::render() const {
|
||||
if (enabled_) {
|
||||
@@ -52,11 +58,18 @@ void Writer::setCaption(const std::string &text) {
|
||||
length_ = text.length();
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
// Establece el valor de la variable (frames)
|
||||
void Writer::setSpeed(int value) {
|
||||
// Convierte frames a milisegundos (frames * 16.67ms)
|
||||
constexpr float FRAME_TIME_MS = 1000.0f / 60.0f;
|
||||
speed_ms_ = static_cast<float>(value) * FRAME_TIME_MS;
|
||||
constexpr float FRAME_TIME_MS = 16.67f;
|
||||
speed_interval_ = static_cast<float>(value) * FRAME_TIME_MS;
|
||||
writing_timer_ = 0.0f;
|
||||
}
|
||||
|
||||
// Establece la velocidad en segundos entre caracteres
|
||||
void Writer::setSpeedS(float value) {
|
||||
// Convierte segundos a milisegundos para consistencia interna
|
||||
speed_interval_ = value * 1000.0f;
|
||||
writing_timer_ = 0.0f;
|
||||
}
|
||||
|
||||
@@ -76,6 +89,12 @@ void Writer::setFinishedTimerMs(float time_ms) {
|
||||
enabled_timer_ = 0.0f;
|
||||
}
|
||||
|
||||
// Establece el temporizador para deshabilitar el objeto (en segundos)
|
||||
void Writer::setFinishedTimerS(float time_s) {
|
||||
enabled_timer_target_ = time_s * 1000.0f; // Convertir segundos a milisegundos
|
||||
enabled_timer_ = 0.0f;
|
||||
}
|
||||
|
||||
// Centra la cadena de texto a un punto X
|
||||
void Writer::center(int x) {
|
||||
setPosX(x - (text_->length(caption_, kerning_) / 2));
|
||||
|
||||
Reference in New Issue
Block a user