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

Chapter 2. Sprites, Camera, Action!

We will start our first game by learning how to draw shapes and textures on the screen. SpriteKit makes drawing simple by doing a lot of the hard work and exposing simple classes we can use for rendering. We are free to focus on building great gameplay experiences while SpriteKit performs the mechanical work of the game loop.

To draw an item on the screen, we need to create a new instance of a SpriteKit node. These nodes are simple; we attach a child node to our scene, or to existing nodes, for each item we want to draw. Sprites, particle emitters, and text labels are all considered nodes in SpriteKit.

Note

The game loop is a common game design pattern used to constantly update the game many times per second and maintain the same gameplay speed on fast or slow hardware. SpriteKit wires new nodes into the game loop automatically. As you gain expertise with SpriteKit, you may wish to explore the game loop further to understand what is going on "under the hood".

The topics in this chapter include the following:

  • Preparing your project
  • Drawing your first sprite
  • Animation—movement, scaling, and rotation
  • Working with textures
  • Organizing art into texture atlases
  • Centering the camera on a sprite
主站蜘蛛池模板: 方山县| 梁山县| 怀宁县| 日土县| 留坝县| 嘉峪关市| 南投县| 灵台县| 万源市| 柘荣县| 沾益县| 石门县| 巴林左旗| 荣昌县| 包头市| 龙泉市| 纳雍县| 东丽区| 扶绥县| 石泉县| 苏尼特右旗| 台北市| 安图县| 襄城县| 始兴县| 余庆县| 新闻| 绩溪县| 全州县| 巴彦县| 吉林市| 宜都市| 龙里县| 三都| 北安市| 乌拉特前旗| 普陀区| 沁源县| 丰镇市| 乾安县| 治多县|