Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
class FontManager { public: FontManager(); ~FontManager(); void setFont(std::string p_direction, int p_index); sf::Font FM_getFont(int p_index) const; private: sf::Font m_font[3]; // 1: Cabin, 2: Berlin Sans, 3: arial }; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Button::Button(const Button &otherButton) :active(otherButton.getActive()) { if (&otherButton.getFont() == nullptr) { m_text.setFont(FM_getFont(0)); } else { m_text.setFont(otherButton.getFont()); } m_text.setCharacterSize(otherButton.getSize()); m_text.setPosition(otherButton.getPos()); m_text.setString(otherButton.getString()); m_text.setColor(otherButton.getColor()); } |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C-/C++-Quelltext |
|
1 2 3 4 |
// Konstruktor Button Button(const sf::font& font, ...); Button newButton(ManagerKlasse.getManagedObject("Arial"), ...); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#pragma once #include "Game.h" class FontManager { public: FontManager(); ~FontManager(); void setFont(std::string p_direction, int p_index); void addFont(std::string p_dircetion); sf::Font FM_getFont(int p_index) const; private: std::vector<sf::Font> m_font; // 1: Cabin, 2: Berlin Sans, 3: arial }; |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
angezeigt, was ich eigentlich nicht verstehe, da ich diese Klasse ganz normal eingebunden habe und sogar in game.h vorwärtsdeklariert habe.
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Oder noch besser, Du baust das Ganze so um, dass der FontManager überhaupt nichts aus game.h braucht. Wozu sollte er auch, er ist doch in sich abgeschlossen.Wenn der FontManager einen Pointer auf einer Klasse aus game.h hat, machst du eine Vorwärtsdeklaration für diese Klasse.
Werbeanzeige