SFML community forums
Help => General => Topic started by: Calm530 on November 21, 2016, 05:28:09 pm
-
So, I have a problem with my button class. I know how to make a button in main but I want to make a button "Prefab", so I can easily make several buttons with different sprites.
the first part of code (the code I have in main) works fine, the class doesn't, it doesn't register me even hovering over.
code: http://pastebin.com/sswTTn7k
Gif of problem: https://gyazo.com/51087ff491395fc2aa0d1412063da9db
-
You retrieve the button bounding rect, before the button (sprite) has a texture, thus the button bounding rect is still (0, 0, 0, 0).
I recommend you study again how member variables are initialized and what the difference is between initialization list and in-class initialization. And think about what can already be initalized before the constructor gets "called". :)
-
I fixed it a few hours later, but thanks for the reply, I didn't have time to take post down..