Learn Unity 2017 for iOS Game Development by Allan Fowler & Philip Chu
Author:Allan Fowler & Philip Chu
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA
Tracking the Game
Listing 8-15 shows the variables defined in the FuguBowl script to track the current frame and current ball.
private var state:String; // current state in the state machin
enum Roll {
Ball1,
Ball2,
Ball3
}
Listing 8-15.The Variables in FuguBowl.js That Track the Current Frame and Ball
The variable frame tracks the current frame with an int, ranging from 0 to 9 instead of 1 to 10 because that number will be used as an array index when itâs passed to the FuguBowlPlayer functions.
The variable roll tracks the current roll of the ball and could also have been declared an int, choosing a convention where the numbers 0 to 2 or 1 to 3 represent the three possible balls in a frame. But itâs cleaner to define an enum (short for enumeration), which essentially allows you to define a new type where the value is one from a list of named values. So, roll is declared to be of type Roll, which is an enum with values Ball1, Ball2, or Ball3.
By the way, at this point youâve encountered several different categories of types: primitive types like int and boolean, built-in arrays that contain other types, enums like the Roll enum, structs like Vector3, and classes like GameObject, Component, and FuguBowlPlayer. Of these categories, classes and arrays are reference types, meaning different variables can reference the same instance of that type, and modifications to the instance will be visible through every variable referencing that instance.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
API Testing and Development with Postman by Dave Westerveld(3619)
Learning C# by Developing Games with Unity 2020 by Harrison Ferrone(2615)
Software Architecture for Busy Developers by Stéphane Eyskens(2322)
2021 Beginners Guide to Python Programming Language: A Crash Course to Mastering Python in One Hour by Elmer Gary & Elmer Gary(1884)
Machine Learning for Algorithmic Trading by Stefan Jansen(1629)
Hands-On ROS for Robotics Programming by Bernardo Ronquillo Japón(1572)
Delphi GUI Programming with FireMonkey by Andrea Magni(1457)
Game Development Projects with Unreal Engine by Hammad Fozi & Goncalo Marques & David Pereira & Devin Sherry(1402)
Cloud Native with Kubernetes by Alexander Raul(1374)
Datadog Cloud Monitoring Quick Start Guide by Thomas Kurian Theakanath(1346)
Software Architecture Patterns for Serverless Systems by John Gilbert(1338)
Practical Node-RED Programming by Taiji Hagino(1336)
Automate It with Zapier by Kelly Goss(1318)
Practical System Programming for Rust Developers by Prabhu Eshwarla(1312)
Delphi Programming Projects by William Duarte(1296)
Mastering React Test-Driven Development by Daniel Irvine(1290)
Developing Multi-Platform Apps with Visual Studio Code by Ovais Mehboob Ahmed Khan & Khusro Habib & Chris Dias(1253)
Ghidra Software Reverse Engineering for Beginners by A. P. David(1244)
Learn Spring for Android Application Development by S. M. Mohi Us Sunnat(1235)
