IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

Problème : error: 'm_positionPersonnage' was not declared in this scope


Sujet :

C++

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2013
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2013
    Messages : 5
    Par défaut Problème : error: 'm_positionPersonnage' was not declared in this scope
    mon source Personnage.cpp

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    #include <iostream>
    #include <string>
    #include <SDL/SDL.h>
    #include "Personnage.h"
     
    using namespace std;
     
     
    Personnage::Personnage()
    {
        m_vie=100;
        m_armure=0;
        m_perso=SDL_LoadBMP("image/Joueur/joueur_Droite_1.bmp");
        m_positionPersonnage.x=0;
        m_positionPersonnage.y=0;
     
    }
    Personnage::~Personnage()
    {
      SDL_FreeSurface(m_perso);
    }
     
    void Personnage::nom(std::string nomPersonnage )
    {
        m_nomPersonnage=nomPersonnage;
     
    }
     
    void Personnage::frapper(string frappe)
    {
       if (frappe=="haut")
       {
           m_perso=SDL_LoadBMP("image/Joueur/joueur_Haut_frappe.bmp");
           personnageBlit();
           SDL_Delay(100);
           m_perso=SDL_LoadBMP("image/Joueur/joueur_Haut_1.bmp");
       }
       else if (frappe=="bas")
       {
           m_perso=SDL_LoadBMP("image/Joueur/joueur_Bas_frappe.bmp");
           personnageBlit();
           SDL_Delay(100);
           m_perso=SDL_LoadBMP("image/Joueur/joueur_Bas_1.bmp");
       }
       else if (frappe=="gauche")
       {
           m_perso=SDL_LoadBMP("image/Joueur/joueur_Gauche_frappe.bmp");
           personnageBlit();
           SDL_Delay(100);
           m_perso=SDL_LoadBMP("image/Joueur/joueur_Gauche_1.bmp");
       }
       else if (frappe=="droite")
       {
           m_perso=SDL_LoadBMP("image/Joueur/joueur_Droite_frappe.bmp");
           personnageBlit();
           SDL_Delay(100);
           m_perso=SDL_LoadBMP("image/Joueur/joueur_Droite_1.bmp");
       }
    }
    void Personnage::deplacer(string direction)
    {
        if(direction=="droite")
        {
            m_perso=SDL_LoadBMP("image/Joueur/joueur_Droite_1.bmp");
            m_positionPersonnage.x+=15;
            m_direction=direction;
     
        }
        else if(direction=="gauche")
        {
            m_perso=SDL_LoadBMP("image/Joueur/joueur_Gauche_1.bmp");
            m_positionPersonnage.x-=15;
            m_direction=direction;
        }
        else if(direction=="bas")
        {
            m_perso=SDL_LoadBMP("image/Joueur/joueur_Bas_1.bmp");
            m_positionPersonnage.y+=15;
            m_direction=direction;
        }
        else if(direction=="haut")
        {
            m_perso=SDL_LoadBMP("image/Joueur/joueur_Haut_1.bmp");
            m_positionPersonnage.y-=15;
            m_direction=direction;
        }
     
    }
    void Personnage::personnageBlit()
    {
        SDL_FillRect(SDL_GetVideoSurface(),NULL,SDL_MapRGB(SDL_GetVideoSurface()->format,152,152,255));
        SDL_SetColorKey(m_perso,SDL_SRCCOLORKEY,SDL_MapRGB(m_perso->format,0,0,0));
        SDL_BlitSurface(m_perso,NULL,SDL_GetVideoSurface(),&m_positionPersonnage);
        SDL_Flip(SDL_GetVideoSurface());
     
     
    }
    SDL_Rect position()
    {
     
        return m_positionPersonnage;
    }
     
    string Personnage::direction_actuelle()
    {
       return m_direction;
    }
    mon Personnage.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    #ifndef PERSONNAGE_H_INCLUDED
    #define PERSONNAGE_H_INCLUDED
    #include <string>
    #include <SDL/SDL.h>
    class Personnage
    {
    public:
        Personnage();
        ~Personnage();
        void nom(std::string nomPersonnage );
        void frapper(std::string frappe);
        void deplacer(std::string direction);
        void personnageBlit();
        SDL_Rect position();
        std::string direction_actuelle();
    private:
     
     int m_vie,m_armure,m_degat;
     std::string m_nomPersonnage, m_direction;
     SDL_Surface *m_perso;
     SDL_Rect m_positionPersonnage;
     
     
     
    };
     
    #endif // PERSONNAGE_H_INCLUDED
    mon Probleme

    bonjour/bonsoir

    quand j'appelle la fonction joueur1.position().x (après avoir créé l'objet Joueur1 de type Personnage)

    il me dit cette erreur
    :error: 'm_positionPersonnage' was not declared in this scope
    alors que j'ai bien déclaré m_positionPersonnage dans le Personnage.h


    aidez moi s'il vous plait

  2. #2
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2013
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2013
    Messages : 5
    Par défaut
    c'est bon j'ai trouver j'ai oublier de mettre Personnage:: deven
    position() dans Personnage.cpp

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 4
    Dernier message: 31/07/2013, 16h02
  2. error : 'tr' was not declared in this scope
    Par jimaitou dans le forum Débuter
    Réponses: 3
    Dernier message: 13/05/2009, 13h54
  3. getaddrinfo was not declared in this scope ?
    Par dr.c0der_ dans le forum C
    Réponses: 2
    Dernier message: 30/04/2009, 02h14
  4. QFormLayout was not declared in this scope
    Par kronos85 dans le forum Débuter
    Réponses: 5
    Dernier message: 11/12/2008, 02h30
  5. Réponses: 3
    Dernier message: 03/06/2007, 15h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo