Reputation: 51
For some reason, when i try to call this TitleScreen instance, it gives an error. It used to work before I add a few stuff, unfortunate I can't undo it and now I have no idea how to fix it.
This is where I call the class instance: (The last line on the private section)
The errors that appears:
Type identifier missing - int assumed. Obs. C++ does not support default-int 'tsn': Unknown substitution specifier
#pragma once
//Outras classes
#include "TitleScreen.h"
#include "InputManager.h"
class Telas
{
private:
Telas();
Telas(Telas const&);
void operator=(Telas const&);
InputManager input; //Intância do teclado
TitleScreen tsn; //Instância da tela inicial
public:
~Telas(void);
static Telas& GetInstance();
void Initialize();
void LoadContent();
void UnloadContent();
void Update(ALLEGRO_EVENT event);
void Draw(ALLEGRO_DISPLAY *display);
};
#pragma once
//Outras Classes
#include "InputManager.h"
#include "Telas.h"
//Inclusões Allegro
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
class TitleScreen
{
private:
ALLEGRO_BITMAP* run = NULL;
ALLEGRO_FONT *font1 = NULL, *font2 = NULL;
InputManager input;
bool isDone; //Variável de fluxo da tela inicial
float posx = 0; //Variável local de posição x
int px; //Variável local de auxílio posição px
const float posy = 530; //Variável local de posição y
int timer;
public:
TitleScreen(void);
~TitleScreen(void);
void LoadContents();
void UnloadContents();
void GameTitle(ALLEGRO_DISPLAY* display);
void GameTitleChar(ALLEGRO_DISPLAY* display);
void UpdateTimer(ALLEGRO_EVENT event);
void SetIsDone(bool value);
bool GetIsDone();
};
#include "TitleScreen.h"
TitleScreen::TitleScreen(void){}
TitleScreen::~TitleScreen(void){}
void TitleScreen::LoadContents() {
if (run == NULL) {
px = 0;
timer = 0;
run = al_load_bitmap("Sprite_Run_Full.png");
if (!run) {
al_show_native_message_box(NULL, "Erro", "Erro", "Sprite não carregado", NULL, NULL);
}
}
if (font1 == NULL) {
font1 = al_load_ttf_font("Fonte1.ttf", 70, NULL);
if (!font1) {
al_show_native_message_box(NULL, "Erro", "Erro", "Fonte1 não carregada", NULL, NULL);
}
}
if (font2 == NULL) {
font2 = al_load_ttf_font("Fonte1.ttf", 20, NULL);
if (!font2) {
al_show_native_message_box(NULL, "Erro", "Erro", "Fonte2 não carregada", NULL, NULL);
}
}
}
void TitleScreen::UnloadContents() {
if (run != NULL) {
al_destroy_bitmap(run);
}
if (font1 != NULL) {
al_destroy_font(font1);
}
if (font2 != NULL) {
al_destroy_font(font2);
}
}
void TitleScreen::GameTitle(ALLEGRO_DISPLAY* display) {
al_clear_to_color(al_map_rgba_f(1, 0.714, 0.757, 0));
al_draw_text(font1, al_map_rgb(0, 0, 0), al_get_display_width(display) / 2, 100, ALLEGRO_ALIGN_CENTRE, "Kirbry's Game");
al_draw_text(font2, al_map_rgb(0, 0, 0), al_get_display_width(display) / 2, 200, ALLEGRO_ALIGN_CENTRE, "Press Enter");
}
void TitleScreen::GameTitleChar(ALLEGRO_DISPLAY* display){
posx = (160 * px) / 60;
if (timer % 30 >= 0 && timer % 30 < 30 / 5) {
al_draw_bitmap_region(run, 0, 0, 44, 50, posx, posy, 0);
}
if (timer % 30 >= 30 / 5 && timer % 30 < 2 * 30 / 5) {
al_draw_bitmap_region(run, 44, 0, 44, 50, posx, posy, 0);
}
if (timer % 30 >= 2 * 30 / 5 && timer % 30 < 3 * 30 / 5) {
al_draw_bitmap_region(run, 88, 0, 44, 50, posx, posy, 0);
}
if (timer % 30 >= 3 * 30 / 5 && timer % 30 < 4 * 30 / 5) {
al_draw_bitmap_region(run, 132, 0, 44, 50, posx, posy, 0);
}
if (timer % 30 >= 4 * 30 / 5 && timer % 30 < 5 * 30 / 5) {
al_draw_bitmap_region(run, 176, 0, 44, 50, posx, posy, 0);
}
}
void TitleScreen::UpdateTimer(ALLEGRO_EVENT event) {
if (event.type == ALLEGRO_EVENT_TIMER) {
if (timer < 60) {
timer++;
}
else {
timer = 0;
}
if (px > 300) {
px = -17;
}
else {
px++;
}
}
}
void TitleScreen::SetIsDone(bool value){
isDone = value;
}
bool TitleScreen::GetIsDone(){
return isDone;
}
Upvotes: 2
Views: 63
Reputation: 81926
You have a loop in your #includes:
Read Resolve build errors due to circular dependency amongst classes for more details.
That being said, it's not clear why TitleScreen.h needs to include Telas.h.
Upvotes: 1
Reputation: 1995
The problem is in the assignment operator: it returns the result, so it can't be declared as void
.
Change the line:
void operator=(Telas const&);
to
Telas& operator=(Telas const&);
then fix the implementation of this operator.
Upvotes: 0