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

Examining the demo code

Let's quickly explore the demo code. Do not worry about understanding everything just yet; we will cover each element in depth later. At this point, I am hoping you will acclimatize to the development environment and pick up a few things along the way. If you are stuck, keep going! Things will actually get simpler in the next chapter, once we clear away the SpriteKit demo and start on our own game.

Make sure you have GameScene.swift open in Xcode.

The demo GameScene class implements some functions you will use in your games. Let's examine these functions. Feel free to read the code inside each function, but I do not expect you to understand the specific code just yet:

  • The game invokes the didMove function whenever it switches to the GameScene. You can think of it a bit like an initialize, or main, function for the scene. The SpriteKit demo uses it to draw the Hello, World text to the screen and set up the spinning square shape that shows up when we tap.
  • There are seven functions involving touch, which handle the user's touch input to the iOS device screen. The SpriteKit demo uses these functions to spawn the spinning square wherever we touch the screen. Do not worry about understanding these functions at this time.
  • The update function runs once for every frame drawn to the screen. The SpriteKit demo does not use this function, but we may have reason to implement it later.
主站蜘蛛池模板: 方正县| 平乡县| 屯留县| 晴隆县| 合肥市| 高要市| 和静县| 海淀区| 砀山县| 崇仁县| 潼南县| 左贡县| 疏勒县| 清原| 衡山县| 巴东县| 新田县| 连云港市| 乌鲁木齐市| 阜新| 萨嘎县| 中方县| 托克托县| 崇信县| 柘城县| 鹿泉市| 申扎县| 蓬莱市| 白河县| 天等县| 保德县| 新密市| 军事| 秭归县| 铅山县| 留坝县| 泰州市| 砀山县| 禹州市| 阆中市| 景泰县|