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

Pages: [1]
1
So today I was working on GUI code and I was wondering why not let sf::Event hold a reference to the window that it was caused in? I think this is a small change that can make a great improvement, as having to pass a window around everytime you wanna map mouse coordinates is quite the bother.

What do you think? :)

Props
Mark

2
Audio / Re: Trouble with a load music function
« on: September 13, 2015, 02:09:46 am »
You would put it /somewhere/ outside of any methods, for example in a header file or above your main method.

3
Audio / Re: Trouble with a load music function
« on: September 13, 2015, 02:06:07 am »
Bit much too explain really. :P
I recommend you read up on scope's, pointer's and references and namespaces (namespaces really aren't a big topic, but an incredibly useful one for that.

As for now, that code will work for creating a namespace, you would just access it in the following way:

namespace foo {
  static void loadMusicFromFile(sf::Music& music, std::string filepath){
     // load music
  }
};
sf::Music menu_music;
foo::loadMusicFromFile(menu_music, "./assets/menuMusic.vav");

4
Audio / Re: Trouble with a load music function
« on: September 13, 2015, 01:55:26 am »
Ignoring the design in general for a second, thing number 1 would be you are passing the sf::Music object as a copy, where you really should as a reference. Also I really wouldn't use a class for that, you can instead just create a namespace with a static method.

namespace foo { // Insert a nifty name, util or something
    static void loadFromFile(sf::Music& file, std::string filepath){
        //.... load file and throw errors etc.
    }
}
 


5
General discussions / Re: Why use SFML over SDL?
« on: July 13, 2015, 04:53:14 am »
I don't know how valid this still is, but I found this:
http://en.sfml-dev.org/forums/index.php?topic=43.0

6
Graphics / Re: Dynamic vertexarray
« on: February 08, 2015, 02:40:38 pm »
The awnser to that is creating a sf::Vertex*. Something like this:

sf::Vertex* v = vertexarray[4 * xCoords + (yCoords * mapHeight)];

Then you have a pointer to the first vertex of the quad that you wan't to edit and can access the folliing with:

v[0].pos....
v[1].pos....
etc. etc.

The code might defer a bit depending on how you map is laid out.

7
Graphics / Re: Issues with Text objects in classes
« on: November 20, 2014, 02:38:37 am »
Okay I updated to the most recent nightly build (I was to lazy to build from source) and now everything works nicely. Thank you alot. Still wondering what was causing the problem, I am pretty sure that I built correctly.
Well, but the fact that it works is good enough.

Thanks :D

8
Graphics / Re: Issues with Text objects in classes
« on: November 20, 2014, 02:26:23 am »
Okay thank you alot for doing that :D
I am going to rebuild sfml now and look if that changes anything. About the exit(0) thing, I just started doing that at some point, dunno why.:P

Edit:: And in the actual project where I had the error I do actually .close the window at cleanup, no worrys :D

9
Graphics / Issues with Text objects in classes
« on: November 19, 2014, 11:24:04 pm »
Hello(?)

I am having a problem with sf::Text object in classes, I was able to break the problem down to this: http://hastebin.com/ofeyozesay.avrasm

Just the pure fact that I make a call to .setString makes the program crash at TestClass::draw, because of access violation.
Callstack comes down to win.draw(testShape) in TestClass.

OS: Win7
I am using SFML 2.1 with dynamic linking

Thanks for helping.

Pages: [1]
anything