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

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.

主站蜘蛛池模板: 东乌珠穆沁旗| 白山市| 黄山市| 惠来县| 屯门区| 沅陵县| 靖远县| 罗定市| 通许县| 民县| 淮南市| 连云港市| 凌源市| 青冈县| 壶关县| 梧州市| 尚志市| 平山县| 汝城县| 嘉善县| 阿拉尔市| 越西县| 泰宁县| 青川县| 大田县| 八宿县| 平邑县| 托克逊县| 夏津县| 德昌县| 德庆县| 合阳县| 泰顺县| 进贤县| 碌曲县| 海城市| 古丈县| 芒康县| 天气| 逊克县| 定南县|