Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Erro com classes


EMX

Pergunta

fui brincar com POO(G) e deu esse erro medonho que não to conseguindo resolver, dai vim aqui pra abusarem vocês do forum pra me da uma maozinha com essa gambiarra, qualquer ajuda é bem vinda :rolleyes:

Segue o erro e as classes, se precisar posto o fonte depois.

In member function `void CNave::mostrar()':|

CNave.cpp|56|error: no matching function for call to `CNave::Blit_Imagem(int&, int&, SDL_Surface*&, SDL_Surface*&)'|

CInitFuncs.h|23|note: candidates are: void CInitFuncs::Blit_Imagem(int, int, SDL_Surface*, SDL_Surface*, SDL_Rect*)|

||=== Build finished: 1 errors, 0 warnings ===|

class CInitFuncs{
    protected:
        SDL_Surface *tela;
        SDL_Surface *img_nave;
        SDL_Surface *bg;
        SDL_Event evento;

    public:
        bool Inicializacao();
        SDL_Surface *Carregar_imagem(string arquivo);
        void Strip_imagem(SDL_Rect Rects[], SDL_Surface *Strip, int div_x, int div_y);
        void Blit_Imagem(int x, int y, SDL_Surface *Fonte, SDL_Surface *Destino, SDL_Rect *rect);
        bool Carregar_arquivos();
        bool AtualizarTela();
        bool Controle_Evento();
        void Finalizar(void);

};

class CNave: public CInitFuncs{
    private:
        int x, y;
        int Velocidade_x, Velocidade_y;

    public:
        CNave();
        void controle_teclado();
        void mover();
        void mostrar();
};

Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0
CNave.cpp|56|error: no matching function for call to `CNave::Blit_Imagem(int&, int&, SDL_Surface*&, SDL_Surface*&)'|

CInitFuncs.h|23|note: candidates are: void CInitFuncs::Blit_Imagem(int, int, SDL_Surface*, SDL_Surface*, SDL_Rect*)|

cara mostra pra gente qual são essas linhas 56 (CNave.cpp) e 23 (CInitFuncs.h) se não a gente não vai saber, mas o q parece é q você ta chamando o metodo mas não ta passando o ultimo parametro do tipo SDL_Rect.

Link para o comentário
Compartilhar em outros sites

  • 0

opa foi mal XD

vou postar o source mermo

// CInitFuncs.h
#ifndef _CINITFUNCS_H
#define _CINITFUNCS_H

#include <iostream>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <string>

using namespace std;

class CInitFuncs{
    protected:
        SDL_Surface *tela;
        SDL_Surface *img_nave;
        SDL_Surface *bg;
        SDL_Event evento;

    public:
        bool Inicializacao();
        SDL_Surface *Carregar_imagem(string arquivo);
        void Strip_imagem(SDL_Rect Rects[], SDL_Surface *Strip, int div_x, int div_y);
        void Blit_Imagem(int x, int y, SDL_Surface *Fonte, SDL_Surface *Destino, SDL_Rect *rect);
        bool Carregar_arquivos();
        bool AtualizarTela();
        bool Controle_Evento();
        void Finalizar(void);

};

#endif

//==============================================================
// CInitFuncs.cpp
#include "CInitFuncs.h"

// FUNCOES
bool CInitFuncs::Inicializacao(){
    if(SDL_Init(SDL_INIT_EVERYTHING) == -1){
        cerr << "Não foi possivel inicar o SDL. ERRO: " << SDL_GetError();
        return false;
    }

    SDL_WM_SetCaption("Inveideris", NULL);

    tela = SDL_SetVideoMode(800, 600, 32, SDL_ANYFORMAT);
    if(tela == NULL){
        cerr << "Não foi possivel iniciar o vídeo. ERRO: " << SDL_GetError();
        return false;
    }

    if(TTF_Init() == -1){
        cerr << "Não foi possivel iniciar o TTF. ERRO: " << SDL_GetError();
        return false;
    }
    return true;
}

SDL_Surface *CInitFuncs::Carregar_imagem(string arquivo){
    SDL_Surface *ImagemCarregada = NULL;
    SDL_Surface *ImagemConvertida = NULL;

    ImagemCarregada = IMG_Load(arquivo.c_str());
    if(ImagemCarregada != NULL){
        ImagemConvertida = SDL_DisplayFormat(ImagemCarregada);
        SDL_FreeSurface(ImagemCarregada);
        if(ImagemConvertida != NULL){
            Uint32 chave_cor = SDL_MapRGB(ImagemConvertida->format, 0, 0xFF, 0);
            SDL_SetColorKey(ImagemConvertida, SDL_SRCCOLORKEY, chave_cor);
        }
    }
    return ImagemConvertida;
}

void CInitFuncs::Strip_imagem(SDL_Rect Rects[], SDL_Surface *Strip, int div_x=1, int div_y=1){
    int X, Y, L, A, dividir_largura, dividir_altura;

    X = 0;
    Y = 0;
    dividir_largura = Strip->w/div_x;
    dividir_altura = Strip->h/div_y;
    L = dividir_largura;
    A = dividir_altura;

    for(int i = 0; i < div_x * div_y; i++){
        Rects[i].x = X;
        Rects[i].y = Y;
        Rects[i].w = L;
        Rects[i].h = A;

        X += dividir_largura;
        if(X >= dividir_largura*div_x){
            Y += dividir_altura;
            X = 0;
        }
    }
}

void CInitFuncs::Blit_Imagem(int x, int y, SDL_Surface *Fonte, SDL_Surface *Destino, SDL_Rect *rect = NULL){
    SDL_Rect posicao;
    posicao.x = x;
    posicao.y = y;

    SDL_BlitSurface(Fonte, rect, Destino, &posicao);
}

bool CInitFuncs::Carregar_arquivos(){
    bg = Carregar_imagem("data/bg.png");
    img_nave = Carregar_imagem("data/nave.png");
    if(bg == NULL || img_nave == NULL){
        return false;
    }
    // arquivos
    return true;
}

bool CInitFuncs::AtualizarTela(){
    if(SDL_Flip(tela) == -1){
        return false;
    }
    return true;
}

bool CInitFuncs::Controle_Evento(){
    bool sair = false;

    while(SDL_PollEvent(&evento)){
        switch(evento.type){
            case SDL_QUIT:
                sair = true;
                break;

            /*case SDL_KEYDOWN:
                switch(evento.key.keysym.sym){
                    case SDLK_ESCAPE:
                        sair = true;
                        break;

                    case SDLK_LEFT:
                        pos_x -= 5;
                        break;

                    case SDLK_RIGHT:
                        pos_x += 5;
                        break;
                }*/
        }
    }
    return sair;
}

void CInitFuncs::Finalizar(void){
    SDL_FreeSurface(tela);
    SDL_FreeSurface(bg);
    SDL_FreeSurface(img_nave);
    TTF_Quit();
    SDL_Quit();
}

//===============================================================
// CNave.h
#ifndef _CNAVE_H
#define _CNAVE_H

#include <SDL.h>
#include <SDL_image.h>
#include "CInitFuncs.h"

class CNave: public CInitFuncs{
    private:
        int x, y;
        int Velocidade_x, Velocidade_y;

    public:
        CNave();
        void controle_teclado();
        void mover();
        void mostrar();
};

#endif

// ==========================================================================
//CNave.cpp
#include "CNave.h"

CNave::CNave(){
    x = 0;
    y = 0;

    Velocidade_x = 0;
    Velocidade_y = 0;
}

void CNave::controle_teclado(){/*
    if(evento.type == SDL_KEYDOWN){
        switch(evento.key.keysym.sym){
            case SDLK_UP:
                Velocidade_y -= 5;

            case SDLK_DOWN:
                Velocidade_y += 5;

            case SDLK_LEFT:
                Velocidade_x -= 5;

            case SDLK_RIGHT:
                Velocidade_x += 5;
        }
    }
    else if(evento.type == SDL_KEYUP){
        switch(evento.key.keysym.sym){
            case SDLK_UP:
                Velocidade_y += 5;

            case SDLK_DOWN:
                Velocidade_y -= 5;

            case SDLK_LEFT:
                Velocidade_x += 5;

            case SDLK_RIGHT:
                Velocidade_x -= 5;
        }
    }*/
}

void CNave::mover(){
    x += Velocidade_x;
    if((x < 0) || (x + img_nave->w > tela->w)){
        x -= Velocidade_x;
    }
    y += Velocidade_y;
    if((y < 0) || (y + img_nave->h > tela->h)){
        y -= Velocidade_y;
    }
}

void CNave::mostrar(){
    Blit_Imagem(x, y, img_nave, tela);
}

acho q isso já da :blink:

Editado por EMX
Link para o comentário
Compartilhar em outros sites

  • 0
é como eu falei, o problema ta aqui ó:

void CNave::mostrar(){
    Blit_Imagem(x, y, img_nave, tela);
}

o Blit_Imagem tem 5 parametros e você ta passando só 4.

mermao num é que era mermo :blink:

isso que da usar os codigo dos outros sem saber como o bixo funciona, mas de qualquer jeito já arrumei pra poder usar o rect MuAhaUhA

vlw ai kuroi, vlw mermo :rolleyes:

Editado por EMX
Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...