Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKhatharr

Posted 10 November 2012 - 01:06 PM

[source lang="cpp"]struct Bounds { //or whatever name describes what the thing actually is int width; int height;};using namespace std;using namespace sf;//Are you modifying these string objects? If not then there's no need to copy them - and they should be const.int menuPreload(const string &theme, const string &theme_on, Texture &button, Texture &button_on, Bounds* dims) { //Please don't just abort the program if there's an error. //Return error codes describing the problem so you can try to solve it! //(Or release held resources and show a message if you can't.) if(!button.loadFromFile(theme)){return 4;} if(!button_on.loadFromFile(theme_on)){return 5;} Sprite sprite(button); something thing = sprite.getLocalBounds(); dims->width = thing.width; dims->height = thing.height; return 0;}Texture button;Texture button_on;Bounds myBounds;menuPreload(config["Button"], config["Button_On"], button, button_on, &myBounds);[/source]

#1Khatharr

Posted 09 November 2012 - 04:12 AM

[source lang="cpp"]struct Bounds { //or whatever name describes what the thing actually is int width; int height;};using namespace std;using namespace sf;//Are you modifying these string objects? If not then there's no need to reference/copy/etc - and they should be const.int menuPreload(const string theme, const string theme_on, Texture &button, Texture &button_on, Bounds* dims) { //Please don't just abort the program if there's an error. //Return error codes describing the problem so you can try to solve it! //(Or release held resources and show a message if you can't.) if(!button.loadFromFile(theme)){return 4;} if(!button_on.loadFromFile(theme_on)){return 5;} Sprite sprite(button); something thing = sprite.getLocalBounds(); dims->width = thing.width; dims->height = thing.height; return 0;}Texture button;Texture button_on;Bounds myBounds;menuPreload(config["Button"], config["Button_On"], button, button_on, &myBounds); [/source]

PARTNERS