Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
GameMaker Cookbook

You're reading from   GameMaker Cookbook Over 50 hands-on recipes to help you build exhilarating games using the robust GameMaker system

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781784399849
Length 212 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Game Plan – Creating Basic Gameplay FREE CHAPTER 2. It's Under Control – Exploring Various Control Schemes 3. Let's Move It – Advanced Movement and Layout 4. Let's Get Physical – Using GameMaker's Physics System 5. Now Hear This! – Music and Sound Effects 6. It's All GUI! - Creating Graphical User Interface and Menus 7. Saving the Day – Saving Game Data 8. Light 'em up! – Enhancing Your Game with Lighting Techniques 9. Particle Man, Particle Man – Adding Polish to Your Game with Visual Effects and Particles 10. Hello, World – Creating New Dimensions of Play Through Networking Index

Making your HUD scalable


Have you ever played a game that didn't quite fit your screen? It's frustrating, isn't it? In a perfect world, your game would work perfectly on any device. Since that's not the case, however, you'll need to make some adjustments if you want to create a game that will fit at least most devices. Let's see what it takes to scale your game to fit screens of different sizes and ratios.

Getting ready

For this recipe, we'll use the game that we created previously. Open the project file and follow the given steps, but make sure Allow the player to resize the game window is activated and Keep aspect ratio is selected under Global Game Settings.

How to do it

  1. Open obj_display.

  2. Under the DrawGUI event, open the code block.

  3. Enter the following code above the existing code:

    display_w = 1024;
    display_h = 768;
    ratio = display_get_width()/display_get_height();
    if ratio > 1
    {
        adjust_w = display_h * ratio;
        adjust_h = display_h;
        display_set_gui_size(display_h * ratio, display_h...
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 $19.99/month. Cancel anytime
Banner background image