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 - Innkeeper

Pages: [1]
1
Graphics / Re: Textures and Sprites inside a class(beginner)
« on: December 18, 2020, 11:35:10 am »
Thank you for the advice and reply. I didnt know the setTexture function

2
Graphics / Re: Textures and Sprites inside a class(beginner)
« on: December 17, 2020, 10:55:23 pm »
Thank you for the reply. I corrected the drawHero function but Im getting this error from my constructor.at the s_wizard(wizard) part   ;  call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type

Hero::Hero()
{
        wizard.loadFromFile("files/magician.png");
        s_wizard(wizard); // error
       

       
}

 

it seems like Im doing something wrong while creating sprite.What should I do?

3
Graphics / Textures and Sprites inside a class(beginner)
« on: December 17, 2020, 08:14:07 pm »
Hello Im trying to use a texture and sprite inside a class I created but it didnt work with the way I tried and I need help
This is my Hero.h file

#include<SFML/Graphics.hpp>

#include<iostream>

class Hero
{

         Texture wizard;
        Sprite s_wizard;

        Hero();
        void drawHero();
};
 

This is my Hero.cpp file

#include<SFML/Graphics.hpp>


using namespace sf;

Hero::Hero()
{
        wizard.loadFromFile("files/magician.png");  // I want to load the texture inside contstructor
        s_wizard(wizard);
       
       
}

void Hero::drawHero()
{
       
}

 

in the drawHero function I want to draw this sprite using a window I created in main file but I dont know how to that.Any help is appreciated.Thank you


Pages: [1]
anything