Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
SFML Game Development By Example

You're reading from   SFML Game Development By Example Create and develop exciting games from start to finish using SFML

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781785287343
Length 522 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Raimondas Pupius Raimondas Pupius
Author Profile Icon Raimondas Pupius
Raimondas Pupius
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

SFML Game Development By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. It's Alive! It's Alive! – Setup and First Program 2. Give It Some Structure – Building the Game Framework FREE CHAPTER 3. Get Your Hands Dirty – What You Need to Know 4. Grab That Joystick – Input and Event Management 5. Can I Pause This? – Application States 6. Set It in Motion! – Animating and Moving around Your World 7. Rediscovering Fire – Common Game Design Elements 8. The More You Know – Common Game Programming Patterns 9. A Breath of Fresh Air – Entity Component System Continued 10. Can I Click This? – GUI Fundamentals 11. Don't Touch the Red Button! – Implementing the GUI 12. Can You Hear Me Now? – Sound and Music 13. We Have Contact! – Networking Basics 14. Come Play with Us! – Multiplayer Subtleties Index

The label element


A label element is the simplest GUI type yet. It supports all of the default stylistic features but it doesn't do much else other than contain a certain string value that can be loaded in or set at runtime.

Let's take a look at its constructor and destructor:

GUI_Label::GUI_Label(const std::string& l_name,
  GUI_Interface* l_owner)
  : GUI_Element(l_name, GUI_ElementType::Label, l_owner){}

This is nothing short of child's play in comparison to the code we've written before. Its name, type, and owner are set up in the initializer list and there's nothing else to it.

The de-serialization of this type of element is also fairly simple. Recall the following line from an interface file:

Element Label TestLabel 0 0 Default.style "Some text"

Since the GUI_Manager class takes care of all of this information except the last part, the ReadIn method of this element might look like this:

void GUI_Label::ReadIn(std::stringstream& l_stream){
    std::string content;
    Utils::ReadQuotedString...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime
Visually different images