コンストラクタをメインプログラムで呼び出すにはどうしたらいいのでしょうか?
あとコンストラクタは初期化という風に考えていますが、考えはあっているでしょうか?
今やろうとしてることとしては
Basic.h
class Basic{
public:
//! コンストラクタ
Basic();
//! 更新処理
virtual void update();
//! 描画処理
virtual void draw();
protected:
//! 座標
Vector2 pos;
//! 移動量
Vector2 mov;
//! 半径
int radius;
};
Basic::Basic()
{
pos._x = 0;
pos._y = 0;
mov._x = 0;
mov._y = 0;
radius = 0;
}
void Basic::update()
{
}
void Basic::draw()
{
}
class Circle : public Basic{
public:
//! コンストラクタ
Circle();
//! 更新処理
virtual void update();
//! 描画処理
virtual void draw();
private:
Vector2 Mat_pos; //!< 配列のポジション
int goal_count;
bool blow_possible; //!< 吹き飛ばし可能かどうか
bool action_possible; //!< アクション可能かどうか
bool goal_flag; //!< ゴールしてるかどうか
int stage; //!< ステージ切り替え
};
Circle::Circle()
{
pos._x = 0;
pos._y = 0;
mov._x = 0;
mov._y = 0;
radius = 15;
goal_count = 0;
blow_possible = false;
action_possible = false;
goal_flag = false;
}
void Circle::update()
{
}
void Circle::draw()
{
}
class testApp : public ofBaseApp{
Circle circle; // 玉クラス
public:
void setup();
void update();
void draw();
void keyPressed (int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
};
必要のないようなソースは省いたので、必要なものがあったら教えてください。
#includeは一つのヘッダファイルにまとめてそれぞれのCppで読み込んでいます。