SFML community forums
Help => Graphics => Topic started by: supdawg on December 04, 2012, 08:43:40 pm
-
i want to create an sf::Text which has a few words of text in the middle of the screen and right below that more words of text.
e.g.
New Game
Exit
something like that. do i need 2 sf::Texts? or is there a way to do it with one sf::Text?
-
One text and the '\n' character is enough.
But in the long term, you want multiple sf::Text instances for your menu, to allow hover effects and mouse click recognition.
-
Yes, I agree with Nexus, you'll want multiple text objects for a menu.
In fact, you may even create a "MenuItem" object that contains a text object - for each item on your menu, to make things nice and simple :)
-
hmm. i see thats a cool approach. but im being over whelmed with all the classes and headers. for a simple project, how many headers/source files should there be on average? i already have 9. ScreenManager, InputManager, TitleScreen, SplashScreen, Animation, FadeAnimation, GameScreen, MenuScreen and main. am i on the right track in terms of splitting up code into files?
-
like for example, for the MenuItem object, i would need to create another class and etc. etc. im finding it hard to decide whether to split a task up into a different thing or just do it in the same cpp file.
-
and for animations (such as choosing menu options with arrow keys and doing some animations when pressing arrow keys) should i just keep creating classes that inherit from my Animation class, or should i incorporate it into another class (e.g. coding the animation of choosing a menu option in the MenuScreen class)? some advice would be great :)
-
Hehe it's a lot to think about, isn't it :P
Well, in my current engine, I've got just under 50 classes for the engine alone - not including the actual classes for the game itself. About 8 classes for menu related stuff (menus, buttons, lists, etc.).
It's all a matter of what you want to do, and how much effort you're willing to put in now to save you time later.
For example, I've used this engine for about 4 prototype games, so I've saved a LOT of time using the same code. It's much more flexible.
-
holy 50 classes!? right now i only have about 7 but i absolutely understand why its important to split tasks. it does make it a lot easier in the long run. but one more question. how exactly do you manage editing many classes? and i assume you have a makefile that you use to compile everything right? i tried creating a makefile and it works, but not like its supposed to. a makefile is supposed to compile only the recently changed files but my makefile compiles all files all the time no matter what.
but i did split everything up. i have a few directories such as Headers, Source, Images, Fonts
-
I'm using C#, so it makes all those annoying little things go away :D
I just create a new project, add in the SFML stuff, and away I go!
C/C++ is so old fashioned ;)
hehe...