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

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.

主站蜘蛛池模板: 富蕴县| 平山县| 涟水县| 海丰县| 日照市| 南乐县| 鸡东县| 龙泉市| 社会| 保康县| 土默特左旗| 乌兰浩特市| 蓬安县| 萝北县| 海林市| 左权县| 安图县| 新巴尔虎右旗| 博白县| 桃江县| 石城县| 永川市| 临朐县| 鸡西市| 丰台区| 鞍山市| 玉屏| 天峨县| 衢州市| 扶余县| 卢湾区| 凌云县| 苍溪县| 荃湾区| 苍梧县| 义马市| 丰镇市| 柳州市| 万安县| 左贡县| 桐城市|