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 - 4B

Pages: 1 [2]
16
Graphics / Re: Exception while pushing back a sf::Text with sf::Font
« on: April 10, 2014, 08:33:44 pm »
Thanks. So I just had to define my sf::Font outside the function.  :-[

Well, sure I will post a "runable" code-snippet in the future, but since the error was already found I just wanted to know how to fix it.


-Thread can be closed

17
Graphics / Exception while pushing back a sf::Text with sf::Font
« on: April 10, 2014, 08:14:09 pm »
Hello.

My current code to draw a button looks like this:

namespace foo
{
 std::vector<std::pair<sf::Text, sf::RectangleShape>> buttons;
 void newButton(...)
 {
  sf::Font bla;
  bla.loadFromFile("...");

  sf::text blub;
  blub.setFont(bla);

  buttons.push_back(std::make_pair(blub,  rectangle));
  //I think i can leave the rectangle-initialization out, because this works fine
 }
 void drawButtons(sf::RenderWindow &window)
 {
  for(std::pair<sf::Text, sf::RectangleShape> b : buttons)
  {
   window.draw(b.second);
   window.draw(b.first); //It fails here, because I set the Font
  }
 }
}
 

What I'm doing wrong? Obviously I'm not supposed to add the font before pushing it on a vector, but I need the font set[complet size of the sf::Text] for the rectangle-initialization.

18
SFML projects / Re: My little collection to short SFML Code
« on: April 09, 2014, 07:19:44 pm »
I hope i used the "const" right and github as it is expected to be used.

https://github.com/4B/FuncCollection/blob/master/SFMLib.hpp

@zsbzsb like I said in my previous post "corrected the little mistake.." I noticed it, but thanks. =)

Everyone feel free to use it, I don't want to license anything.

19
SFML projects / Re: My little collection to short SFML Code
« on: April 09, 2014, 06:49:02 pm »
@StormWingDelta I'm not sure if it's necessary to return both coordinates in one function. Sometimes you just need one coordinate(For example in a space shooter[1D-movement]). If you convince me I'll add that.
And I'm not sure what a line collision is good for.

@Nexus Thanks for this hint. I didn't really understood when to use const until now.


-Added circle collision
-Added world/window-coordinates(also corrected the little mistake which I made in the first version)

20
SFML projects / My little collection to short SFML Code
« on: April 09, 2014, 06:07:40 pm »
Hello.

I recently made a little collection of functions which make my life with SFML easier.

SFML is my favorite library for graphical purposes, but I always wondered why there has to be so much code just to create a colorful rectangle or whatever so I decided to create a little library that helps me being faster.

Here you can find the SFMLib: https://github.com/4B/FuncCollection/blob/master/SFMLib.hpp

Feel free to give any suggestions and please tell me if I did something wrong.



Edit:
I forgot to talk about the name. Of course it won't be named as "SFMLib" if there will be a release one day. It's just a codename.

Pages: 1 [2]
anything