Bonjour,

J'ai créé une classe MySprite qui contient toutes les informations sur un sprite et je veux ensuite dériver mes sprites de cette classe.
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
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef MYSPRITE_H
#define MYSPRITE_H
 
#include <windows.h>
#include <sstream>
#include <string>
#include <vector>
#include <d3d9.h>
#include <d3dx9.h>
#include <time.h>
#include <fcntl.h>
#include <io.h> 
#include <iostream>
using namespace std;
 
#pragma once
 
#pragma comment(lib,"d3d9.lib")
#pragma comment(lib,"d3dx9.lib")
 
	/* structures */
	struct STRUCT_Location
	{
		float x,y;
	};
 
	struct STRUCT_Velocity
	{
		float velX, velY;
	};
 
	struct STRUCT_Size
	{
		int width, height;
	};
 
 
class MySprite
{
 
public:
	MySprite();
	MySprite(bool alive, string name, int width, int height, LPDIRECT3DTEXTURE9 texture, int startFrame = 0, int endFrame = 0, int columns = 1, int delay = 10, int direction = 0);
	virtual void reset();
	void animate();
 
	STRUCT_Location getLocation();
	D3DXVECTOR2 getLocationVector2();
	virtual void setLocation(float x,float y);
	virtual void move(float x,float y);
 
	bool isAlive();
	void setAlive(bool alive);
 
	STRUCT_Velocity getVelocity();
	virtual void setVelocity(float velX, float velY);
	virtual void changeVelocity(float velX, float velY);
 
	float getScaling();
	virtual void setScaling(float scaling);
	virtual void changeScaling(float scaling);
 
	float getRotation();
	virtual void setRotation(float angle);
	virtual void changeRotation(float angle);
 
	STRUCT_Location getCenter();
	D3DXVECTOR2 getCenterVector2();
	virtual void setCenter(float x, float y);
 
	STRUCT_Size getSize();
 
	int getCurrentFrame();
	void setCurrentFrame(int i);
 
	int getStartFrame();
	void setStartFrame(int i);
 
	int getEndFrame();
	void setEndFrame(int i);
 
	int getStartTime();
	void setStartTime(int start);
 
	int getDelay();
	void setDelay(int delay);
 
	int getDirection();
	void setDirection(int direction);
 
	int getColumns();
	void setColumns(int columns);
 
	D3DCOLOR getColor();
	void setColor(D3DCOLOR color);
 
	void getTexture(LPDIRECT3DTEXTURE9* texture);
	void setTexture(LPDIRECT3DTEXTURE9* texture);
 
	virtual ~MySprite(void);
 
protected:
	double toRadians(double degrees);
	double toDegrees(double radians);
 
	bool m_alive;
	string m_name;
	STRUCT_Location m_location;
	STRUCT_Location m_center;
	float m_scaling, m_rotation;
	STRUCT_Velocity m_velocity;
	STRUCT_Size m_size;
	int m_currentFrame, m_startFrame, m_endFrame;
	int m_startTime, m_delay, m_direction, m_columns;
	D3DCOLOR m_color;
	LPDIRECT3DTEXTURE9 m_texture;
 
};
 
#endif
Donc avec cela je crée un vrai sprite, disons Bomb :
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
#pragma once
#include "mysprite.h"
class Bomb :
	protected MySprite
{
 
 
public:
	Bomb(bool alive, string name, int width, int height, LPDIRECT3DTEXTURE9 texture, int startFrame = 0, int endFrame = 0, int columns = 1, int delay = 10, int direction = 0);
	void reset();
 
	~Bomb(void);
 
private:
 
};
Mais quand je crée mon objet Bomb et que je veux utiliser la fonction isAlive, le compilateur me dit que ce n'est pas possible car Bomb hérite en protected et pas en public...

Est-ce possible d'hériter des protected et des public ?

Cordialement,

rXp>!<