前提・実現したいこと
rectクラスを継承したPlayerクラスを
extern 宣言したらエラーが出ました
player cpp の
3行目でエラーが出ました
Player g_player;
エラー文を見てますがよくわかりません
visual studio 2017です
発生している問題・エラーメッセージ
Player::Player(void)消去された関数を呼び出そうとしてます
該当のソースコード
C++
1 2#pragma once 3 4#include "Rect.h" 5#include "AnimationController.h" 6 7//独自のデータを定義 8struct Player:Rect 9{ 10 AnimationController m_animationController; 11 12 int Init(); 13 void Update(); 14 void Draw(); 15}; 16 17extern Player g_player;
C++
1#include "Player.h" 2 3Player g_player; //ここでエラーが出ました 4 5int Player::Init() 6{ 7 8 return 0; 9} 10 11void Player::Update() 12{ 13 m_animationController.Update(); 14} 15 16void Player::Draw() 17{ 18 //glBindTexture( 19 // GL_TEXTURE_2D,//GLenum target, 20 // g_texture[t]//GLuint texture 21 //); 22 Rect::Draw(); 23} 24
C++
1#include "Rect.h" 2#include "glut.h" 3#include <stdio.h> 4 5Rect::Rect(float _width, float _height) 6 :m_size(_width, _height),//高さ 7 m_position(vec2()),//幅 8 m_flip(RECT_FLIP_NONE)//クリアする 9{} 10 11Rect::Rect( vec2 const & _size,vec2 const & _position)//幅と高さ 12:m_size(_size)//高さ 13,m_position(_position),//幅 14m_flip(RECT_FLIP_NONE)//クリアする 15{ 16 17} 18 19void Rect::Draw() 20{ 21 ////四角形描画 22 //glRectf( 23 //m_position.x, //GLfloat x1, 24 // m_position.y, //GLfloat y1, 25 //m_position.x+m_size.x, //GLfloat x2, 26 //m_position.y+m_size.y); //GLfloat y2, 27 28 glBegin(GL_QUADS);//ワイヤーフレームでもできる 29 { 30 //反転フラグが建っていたら 31 glTexCoord2f((m_flip&RECT_FLIP_HORIZONTAL)?1:0//反転フラグが建っていたら1建ってなかったら0 32 ,( m_flip&RECT_FLIP_VERTICAL) ? 1 : 0);//GLfloat s, GLfloat t 33 glVertex2fv((GLfloat*)&m_position);//const GLfloat *v 34 35 glTexCoord2f((m_flip&RECT_FLIP_HORIZONTAL) ? 1 : 0, 36 (m_flip&RECT_FLIP_VERTICAL) ? 0 : 1);//GLfloat s, GLfloat t 37 glVertex2fv((GLfloat*)&(m_position+vec2(0,m_size.y)));//const GLfloat *v 38 39 glTexCoord2f((m_flip&RECT_FLIP_HORIZONTAL) ? 0 : 1, 40 (m_flip&RECT_FLIP_VERTICAL) ? 0 : 1);//GLfloat s, GLfloat t 41 glVertex2fv((GLfloat*)&(m_position + m_size));//const GLfloat *v 42 43 glTexCoord2f((m_flip&RECT_FLIP_HORIZONTAL) ? 0 : 1, 44 (m_flip&RECT_FLIP_VERTICAL) ? 1 : 0);//GLfloat s, GLfloat t 45 glVertex2fv((GLfloat*)&(m_position + vec2( m_size.x,0)));//const GLfloat *v 46 } 47 glEnd(); 48} 49 50void Rect::DrawWire() { 51 glPushAttrib(GL_ALL_ATTRIB_BITS);// GLbitfield mask 52 glDisable(GL_TEXTURE_2D); 53 glPolygonMode( 54 GL_FRONT_AND_BACK,//GLenum face, 55 GL_LINE);//線で描画 //GLenum mode); 56 glRectfv( 57 (GLfloat*)&m_position,//const GLfloat *v1, 58 (GLfloat*)&(m_position+m_size)//const GLfloat *v2 59 ); 60 61 glPopAttrib();//終了 62} 63 64bool Rect::Intersect(vec2 const & _point) 65{ 66 //当たり判定 67 return (_point.x >= m_position.x&& 68 _point.x < m_position.x + m_size.x 69 &&_point.y >= m_position.y 70 &&_point.y < m_position.y + m_size.y); 71 72} 73 74bool Rect::Intersect(Rect const & _rect) 75{ 76 return (m_position.x + m_size.x >= _rect.m_position.x&& 77 m_position.x <= _rect.m_position.x + _rect.m_size.x&& 78 m_position.y + m_size.y >= _rect.m_position.y&& 79 m_position.y <= _rect.m_position.y + _rect.m_size.y); 80 81 82} 83
C++
1#pragma once 2#include"glm/glm.hpp" 3 4using namespace glm; 5 6 7#define RECT_FLIP_NONE 0 //初期化 8#define RECT_FLIP_HORIZONTAL (1<<0)//横反転フラグ 9#define RECT_FLIP_VERTICAL (1<<1)//縦反転フラグ 10 11struct Rect 12{ 13 vec2 m_position;//位置を保持 14 vec2 m_size;//大きさを保持 15 int m_flip;//反転を指示 16 17 //コンストラクタ 18 Rect(float _width, float _height); 19 Rect( vec2 const&_size,vec2 const & _position ); 20 21 //描画 22 void Draw(); 23 24 void DrawWire();//ワイヤーを描画 25 //当たり判定 26 bool Intersect(vec2 const& _point); 27 bool Intersect(Rect const& _rect); 28};
試したこと
補足情報(FW/ツールのバージョンなど)
visual studio 2017
回答2件
あなたの回答
tips
プレビュー