Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - rageeph

Pages: [1]
1
General / Re: Setting texture on sprite not working
« on: October 14, 2019, 03:26:21 pm »
ah, thank you.

2
General / Setting texture on sprite not working
« on: October 14, 2019, 04:44:17 am »
I created a header file (level.h) which has a constructor with a texture parameter called 'ImagePath'. I am then saying what it will do in the level.cpp file which is to apply the 'ImagePath' texture to a sprite. I am then getting an error:

level.cpp: In constructor ‘Tile::Tile(const sf::Texture&)’:
level.cpp:5:22: error: no match for call to ‘(sf::Sprite) (const sf::Texture&)’
    5 |  TileSprite(ImagePath);

Here is my code:

level.h
#ifndef LEVEL_H
#define LEVEL_H

#include<SFML/Graphics.hpp>

class Tile: public sf::Drawable {

   public:   
   Tile(const sf::Texture& ImagePath);   
   virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;   
   
   
   private:
         
      sf::Sprite TileSprite;
};

#endif


level.cpp
#include "level.h"

Tile::Tile(const sf::Texture& ImagePath) {
   
   TileSprite(ImagePath);      

}


void Tile::draw(sf::RenderTarget& target, sf::RenderStates states) const {


   //Apply transform here
      
   target.draw(TileSprite,states);
   


}

Pages: [1]