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

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.

主站蜘蛛池模板: 桓仁| 广南县| 久治县| 宁河县| 兴化市| 西乌| 松滋市| 富平县| 乌拉特中旗| 新绛县| 文山县| 天镇县| 洛宁县| 丰台区| 东乌珠穆沁旗| 宜宾市| 阳春市| 沽源县| 卢龙县| 连江县| 光山县| 武穴市| 财经| 松阳县| 垦利县| 利辛县| 扎兰屯市| 滁州市| 丽水市| 徐汇区| 澄江县| 大连市| 邵东县| 揭阳市| 大厂| 游戏| 娄烦县| 柞水县| 枣强县| 东丽区| 尼玛县|