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

Pages: [1]
1
Graphics / Re: Explicitly initializing sprite
« on: July 05, 2023, 06:12:01 pm »
This was actually occurring with version 2.6.0.  I reverted back to 2.5.1 and the error disappeared without having to include the sprite in the initialization list.  Not sure what the problem was.  I also switched over to CLion for my IDE, though I don't think that made any difference because I was still getting the error in CLion with 2.6.0.

2
Graphics / Re: Explicitly initializing sprite
« on: July 05, 2023, 05:44:15 am »
Disregard.  I was able to include the sprite in the initialization list before loading the texture and it worked.

3
Graphics / Explicitly initializing sprite
« on: July 05, 2023, 05:38:07 am »
Hello,

I'm working through a book and trying to create a Game class in a header file which has a sprite as a private variable.  I am getting the error "Constructor for 'Game' must explicitly initialize the member 'm_mushroom' [name of sprite] which does not have a default constructor" when I try to compile and can't seem to figure out why.  I've tried initializing the sprite inside the default constructor by setting the texture, but this apparently doesn't work.  Here is my code for the constructor:

    Game(): m_window("Chapter 2", sf::Vector2u(800,600)) {
        m_mushroomTexture.loadFromFile("path_to_mushroom_image_here");
        m_mushroom.setTexture(m_mushroomTexture);
        m_increment = sf::Vector2i(4,4);
    }

This is with Xcode on macOS.  Any ideas on what I'm doing wrong?  Thanks.

Pages: [1]
anything