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

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.

主站蜘蛛池模板: 聂荣县| 威远县| 弥渡县| 洱源县| 大连市| 西乌珠穆沁旗| 乐至县| 临沧市| 介休市| 合江县| 兴仁县| 吴堡县| 玉树县| 高平市| 阜南县| 桐庐县| 射阳县| 长汀县| 双辽市| 台安县| 越西县| 正镶白旗| 潢川县| 荥阳市| 股票| 垫江县| 墨竹工卡县| 综艺| 莱西市| 儋州市| 海原县| 永宁县| 徐闻县| 宜黄县| 洞头县| 兰溪市| 大港区| 鄯善县| 黎川县| 怀安县| 平遥县|