0%

Book Description

Create your own line of successful 2D games with Unity!

In Detail

If you are looking for a guide to create 2D games using Unity, look no further. With this book, you will learn all the essentials of 2D game development by creating five real-world games in a step-by-step manner throughout the course of this book.

Starting with a blank scene, you will learn all about the new Unity 2D toolset, which will enable you to bring your scene to life. You will create characters, make them move, create some enemies, and then write code to destroy them. After figuring out all the necessities of creating a game, this book will then assist you in making several different games: games with collision, parallax scrolling, Box2D, and more.

By the end of this book, you will not only have created several small games, but you will also have the opportunity to put all your new-found knowledge into creating and deploying a larger, full game.

What You Will Learn

  • Work with Unity's new 2D workflow and create a 2D scene
  • Set the scene with different types of backgrounds, either static or dynamically using a tileset
  • Bring your character to life through simple animations
  • Understand the core concepts of programming by creating basic code that controls a character and destroys an enemy
  • Create buttons and game controls by using code snippets for input detection
  • Develop five 2D games from genres such as classic arcade, endless runner, rogue-like, physics, and space buddy games
  • Add audio and feedback and deploy your games

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Learning Unity 2D Game Development by Example
    1. Table of Contents
    2. Learning Unity 2D Game Development by Example
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code and colored images
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Getting to Know Unity
      1. Overview
      2. Game development's background
      3. Introducing Unity
      4. Setting up Unity
      5. Creating a new 2D project
      6. Unity Editor interface
        1. Toolbar
        2. Scene View
        3. Game View
      7. Project Browser
        1. Creating assets
        2. Searching assets
        3. Setting favorites
          1. The Unity Asset Store
          2. Importing assets
        4. Hierarchy
          1. Parenting
          2. Creating GameObjects
        5. The Inspector
          1. Adding components
      8. Extra Views
        1. Console
          1. Animation
          2. Sprite Editor
          3. Animator
          4. Profiler
      9. Summary
    9. 2. Setting the Scene
      1. Overview
      2. What is a background?
      3. Two methods to set a background
        1. Setting a background using a static image
          1. Importing our asset
        2. Sprite settings within the Inspector
          1. Texture Type
          2. Sprite Mode
          3. Packing Tag
          4. Pixels to Units
          5. Pivot
          6. Filter Mode
          7. Platform Settings
            1. Max size
            2. Format
          8. Applying our settings
        3. Assigning our asset to a GameObject
          1. The toolbar method
          2. The quick alternative method
        4. GameObject Inspector settings
          1. Position background
          2. Color background
          3. Layer background
      4. Setting a background using a tileset
        1. Seamless textures
        2. Corner pieces
        3. The grid settings
        4. Creating a prefab
      5. The resulting environment
        1. Camera settings
        2. Setting the foreground
      6. Summary
    10. 3. Add Some Character
      1. Overview
      2. What is a sprite?
      3. Creating a sprite
        1. Image editing software
        2. Sprite sheet
        3. Raster versus vector
        4. File formats
      4. Importing a sprite
      5. Slicing sprite sheets
        1. Sprite Editor
        2. Manual slicing
          1. Adding and removing a selection area
          2. Toolbar controls
      6. Automatic slicing
        1. Slicing type – automatic
        2. Slicing type – grid
      7. Texture atlasing
        1. What is a texture atlas?
        2. Sprite packer
      8. Adding our character
      9. Sprite Renderer
      10. Animating a sprite
      11. Animation Editor
      12. Dopesheet 2D animation
      13. Animator
      14. Summary
    11. 4. Code Control
      1. Overview
      2. Why do we need code?
        1. Programming languages
        2. Levels of programming languages
          1. Machine language
          2. Assembly language
          3. High-level languages
        3. Scripting languages
        4. UnityScript versus C# versus Boo
      3. Code fundamentals
        1. Data types
        2. Operators
        3. Functions
        4. Conditional statements
          1. If...else
        5. Using comments
        6. Classes
          1. Private versus public
        7. Importing external libraries
        8. Code editor
      4. Hello world
      5. Controlling the character
      6. Destroying the enemy
      7. Coroutines
      8. Namespaces
      9. Unity Scripting Reference
      10. Summary
    12. 5. What's Your Input?
      1. Overview
      2. Input versus output
        1. Input in games
        2. Output in games
      3. Input types
      4. Output types
        1. Visual output
        2. Audio
        3. Controller vibration
      5. Unity Input Manager
      6. Detecting input
      7. Buttons
        1. OnGui
        2. GUILayout.Button
      8. Game controls
        1. Raycasting
      9. Summary
    13. 6. Game #1 – Roguelike
      1. Overview
      2. What is Roguelike?
      3. Adding a background
      4. Animating the hero
        1. The Walking Down animation
        2. The Walking Left animation
        3. The Walking Right animation
        4. The Walking Up animation
      5. Movement controls
        1. Movement Controls Animator
        2. Movement controls script
      6. Randomly spawning enemies
      7. Animating the enemy
      8. Enemy movement
      9. Shooting projectiles
      10. Detecting collisions
      11. Permadeath
      12. End game result
      13. Summary
    14. 7. Game #2 – Classic Arcade
      1. Overview
      2. Sponge antics
        1. Our main character – Spongy
        2. The bathroom
        3. Adding Spongy
        4. Moving left and right
        5. Spawning grime
        6. Spawning acid
      3. Game conditions
        1. Lives
        2. Score
        3. Time
      4. Adding an HUD
      5. Font style
      6. Resource management
      7. The completed game
      8. Summary
    15. 8. Game #3 – Endless Runner
      1. Overview
      2. Infinite
      3. An agile ninja
      4. The ninja character
        1. Running
        2. Jump and Slide
        3. Add Animator parameters
        4. Animator states and transitions
        5. Movement controls
      5. Randomly repeating obstacles
      6. Survival
      7. Parallax scrolling
      8. Add pizzazz with particle effects
      9. Displaying the timer
      10. The result
      11. How to expand the game?
      12. Summary
    16. 9. Game #4 – Physics Fun
      1. Overview
      2. The basics of physics
        1. Physics found in the real world
      3. Physics 2D
      4. What is Box2D?
      5. Steps to create bodies
      6. Let's simulate the world
        1. The environment
          1. Creating the scene
          2. Creating the background
          3. The foreground
          4. Adding the props
            1. Adding the crate
            2. Adding the plank
        2. Shooting the cannonballs
        3. Creating the cannonballs
      7. The final result
      8. How do we extend it?
      9. Summary
    17. 10. You Are Ready!
      1. Overview
      2. Audio
        1. Music
        2. Sound effects
      3. Saving and loading
      4. Creating a trigger
      5. Cameras
      6. Multiplayer
      7. Putting it all together
        1. The first scene
        2. The galaxy
        3. Platforms
        4. Triggers
        5. The lava
        6. UFO beam
      8. Adding audio
      9. The camera
      10. Saving and loading
      11. Space Buddy the alien
        1. Space Buddy script
        2. Positioning
      12. The second scene
        1. The final result
      13. Deployment
      14. Your journey ahead
      15. A plethora of resources
        1. Online resources
        2. Offline events
        3. Free resources
        4. Hosting games
      16. Social media
      17. Summary
    18. Index
18.221.129.19