- Cocos2d Cross-Platform Game Development Cookbook(Second Edition)
- Siddharth Shekar
- 243字
- 2021-07-16 09:43:44
The 2D coordinate system
In case of 2D game development, we just have two coordinate systems to worry about. The first is the screen coordinate system, and the other is the object coordinate system.
In 2D, whenever we place an object on screen, we always think as to how far the object is from the lower-left part of the screen. This is because the lower-left part of the screen is the origin and not the center of the screen. That is why if you place a sprite without changing its position, it will be created in the lower-left part of the screen. The screen origin, or the (0,0) position, is in the lower-left part of the screen. If you want to place the sprite at the center of the screen, you need to set the position to half the width and the height of the position property. As everything is with respect to the lower-left part of the screen, this is called the screen coordinate system.
The object coordinate system refers to the sprite itself. The center of the sprite is at the center of the object, unlike the screen, which has its origin in the lower-left part. The center of the sprite is called the anchor point. When you rotate a sprite, it will rotate about its center because its origin is at its center. You can change the origin of the sprite by accessing the anchor point property of the sprite.

- MySQL數據庫管理實戰
- Visual Basic程序開發(學習筆記)
- 跟老齊學Python:輕松入門
- Mastering Rust
- Instant RubyMotion App Development
- Python機器學習經典實例
- H5頁面設計:Mugeda版(微課版)
- RISC-V體系結構編程與實踐(第2版)
- Swift細致入門與最佳實踐
- Visual Basic程序設計實驗指導(第二版)
- Python深度學習原理、算法與案例
- Visual Basic 6.0程序設計實驗教程
- Hands-On Neural Network Programming with C#
- Machine Learning With Go
- OpenCV 3計算機視覺:Python語言實現(原書第2版)