Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering iOS Game Development

You're reading from   Mastering iOS Game Development Mastering iOS Game Development

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher Packt
ISBN-13 9781783554355
Length 228 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Peter Ahlgren Peter Ahlgren
Author Profile Icon Peter Ahlgren
Peter Ahlgren
Miguel DeQuadros Miguel DeQuadros
Author Profile Icon Miguel DeQuadros
Miguel DeQuadros
Arrow right icon
View More author details
Toc

Managing effects

As we've been programming our game so far, we have been haphazardly creating without thinking about how our effects will run on older devices.

Have no fear! Because we can detect which device the player is using and adjust our particle effects and the number of enemies that will spawn on the screen at a time.

To begin, in our GameLevelScene.m file, we will add the following line of code at the top:

#import <sys/utsname.h>

This framework will allow us access to detecting the exact device we are working on.

Just under the @implementation line, add the following function:

NSString* deviceName()
{
    struct utsname systemInfo;
    uname(&systemInfo);

    return [NSString stringWithCString:systemInfo.machine
                              encoding:NSUTF8StringEncoding];
}

Now, if you want to see which device appears, you can add the deviceName() function to the NSLog function in our init section, which would look like this:

NSLog(deviceName());

So, your log will now...

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