I'm trying to write a simple class that represents a missile (for a game). It uses SFML 2.0 and the class is basically a sprite type. Now the only interface function that I want at the moment is the call to 'move'. This is a SFML function that is a member of the Sprite class. So my class inherits from sf::Sprite and sf::Texture.
This is what I have done in the file missile.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#ifndef MISSILE_H
#define MISSILE_H
#include<SFML/Graphics.hpp>
#include<SFML/System.hpp>
class missile : public sf::Sprite, sf::Texture
{
// member functions - perform operations on data members
public:
void move(float offsetX, float offsetY);
private:
// encapsulated data members
static sf::Texture rocket_picture.loadFromFile("/home/neil/game/data/missile.png");
missile.setTexture(rocket_picture);
missile.setScale(0.01f,0.02f);
};
|
When i try to compile it i am getting these errors:
missile.h:15:22: error: expected ‘;’ at end of member declaration
missile.h:15:36: error: expected unqualified-id before ‘.’ token
missile.h:17:9: error: expected unqualified-id before ‘.’ token
missile.h:19:9: error: expected unqualified-id before ‘.’ token
-------
I have tried making some changes to the data members. All the data does is setup the sprite. I tried copying the code i used in main to setup the sprite's image (that works) into the class - but it did not compile.
Basically i want an instance of this class to have the same image! I know it is simple but i am having trouble as i have not used this SFML before. Can anyone help me with this please?