官术网_书友最值得收藏!

What is a method?

When we write a script, we are making lines of code that the computer is going to execute, one line at a time. As we write our code, there will be things that we want our game to execute more than once. For example, we can write a piece of code that adds two numbers. Suppose our game needs to add those two numbers a hundred different times during gameplay. So you'd say, "Wow! I have to write the same code a hundred times to add two numbers together? There has to be a better way."

Let a method take away your typing pain. You just have to write the code to add two numbers once and then give this chunk of code a name, such as AddTwoNumbers(). Now, every time your game needs to add two numbers, don't write the code over and over, just call the AddTwoNumbers() method.

主站蜘蛛池模板: 磐安县| 苏尼特右旗| 格尔木市| 奇台县| 商丘市| 嘉义市| 舞阳县| 运城市| 兴安县| 台东县| 修武县| 台湾省| 萝北县| 武宁县| 鄯善县| 怀远县| 吉安县| 台北县| 普兰县| 五台县| 出国| 潞城市| 左云县| 藁城市| 油尖旺区| 锦屏县| 桂东县| 仙桃市| 政和县| 饶阳县| 高雄县| 通许县| 汉源县| 镇平县| 无极县| 南阳市| 安岳县| 新沂市| 通海县| 莱西市| 高陵县|