diff --git a/doc/demo05_scene_node/image/console.JPG b/doc/demo05_scene_node/image/console.JPG new file mode 100644 index 0000000..a68ca40 Binary files /dev/null and b/doc/demo05_scene_node/image/console.JPG differ diff --git a/doc/demo05_scene_node/image/console.JPG.import b/doc/demo05_scene_node/image/console.JPG.import new file mode 100644 index 0000000..44e6b84 --- /dev/null +++ b/doc/demo05_scene_node/image/console.JPG.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/console.JPG-b4dcc8e77285f268f6074ba14ee6c3f4.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://doc/demo05_scene_node/image/console.JPG" +dest_files=[ "res://.import/console.JPG-b4dcc8e77285f268f6074ba14ee6c3f4.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/doc/demo05_scene_node/image/ios.JPG b/doc/demo05_scene_node/image/ios.JPG new file mode 100644 index 0000000..97f61ff Binary files /dev/null and b/doc/demo05_scene_node/image/ios.JPG differ diff --git a/doc/demo05_scene_node/image/ios.JPG.import b/doc/demo05_scene_node/image/ios.JPG.import new file mode 100644 index 0000000..8acd0e6 --- /dev/null +++ b/doc/demo05_scene_node/image/ios.JPG.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/ios.JPG-d249826948164e79c68bd80ef8548ba6.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://doc/demo05_scene_node/image/ios.JPG" +dest_files=[ "res://.import/ios.JPG-d249826948164e79c68bd80ef8548ba6.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/doc/demo05_scene_node/scene_node.md b/doc/demo05_scene_node/scene_node.md index 7a79fdd..f714aae 100644 --- a/doc/demo05_scene_node/scene_node.md +++ b/doc/demo05_scene_node/scene_node.md @@ -1,11 +1,37 @@ # 1. 屏幕窗口设置 +- Project | Editor Settings | Editor,设置控制台是否隐藏 + ![Image text](image/console.JPG) + - Editor | Editor Settings | Window Placement,设置编辑器运行游戏窗口的位置 ![Image text](image/window01.jpg) - Project | Project Settings | Display,设置游戏窗口的大小等相关参数 ![Image text](image/window02.jpg) +- Project | Project Settings | Display | Hide Home Indicator,ios的 Home 键指示隐藏 + ![Image text](image/ios.JPG) + +# 2. 单位和像素 + +- 屏幕分辨率(屏幕像素),屏幕分辨率是指纵横向上的像素点数,单位是px,4:3 是最常见屏幕比例,显示设置可以看到 + + +- 图片像素 + ![Image text](image/pixel.jpg) + + +- 屏幕像素和图片像素有什么关系 + +``` +在屏幕显示图片时,如果屏幕的长宽比、像素数和图片一致,只需要每个屏幕像素的像素点表示出图片上的像素就可以了,1:1对应显示出来。 +那如果图片像素数和屏幕像素数不一样呢? + +当图片像素大于屏幕像素时,屏幕也是进行合并显示的。 +比如一张1200W像素的图片,要在300W像素的显示器(长宽比一致)上显示,那么系统就需要将图片像素进行四合一计算然后再显示。 +当图片像素数大于屏幕像素数时,高像素图片和低像素图片的显示精细度是一样的! +``` + - DPI(dots per inch),DPI在高分辨率显示器和手机普及之后,调了之后,画面上的字体等会变大变小。 ``` @@ -15,6 +41,10 @@ 这个过程在windows上面就是DWM(desktop windows manager)做了scaling。 ``` +- 在godot中,一般position的1个单位长度等于1个图片像素 + +# 3. 垂直同步 + - Vsync,垂直同步 ``` @@ -27,8 +57,8 @@ 显卡就会暂停处理,等下个垂直同步信号到来后才开始渲染下一帧。 由此可见,当打开垂直同步时,游戏的FPS要受刷新率的制约,对于高端显卡而言,限制了其性能的发挥。 -假设我们选择不等待垂直同步信号(也就是我们平时所说的关闭垂直同步),那 -么游戏中作完一屏画面,显卡和显示器无需等待垂直同步信号就能够開始下一屏图像的绘制,自然能够全然发挥显卡的实力。 +假设我们选择不等待垂直同步信号(也就是我们平时所说的关闭垂直同步), +那么游戏中作完一屏画面,显卡和显示器无需等待垂直同步信号就能够開始下一屏图像的绘制,自然能够全然发挥显卡的实力。 可是不要忘记,正是由于垂直同步的存在,才干使得游戏进程和显示器刷新率同步,使得画面更加平滑和稳定。 取消了垂直同步信号,固然能够换来更快的速度,可是在图像的连续性上势必打折扣。 这也正是非常多朋友抱怨关闭垂直后发现画面不连续的理论原因。 @@ -36,24 +66,7 @@ ![Image text](image/window03.jpg) -- 屏幕分辨率,屏幕分辨率是指纵横向上的像素点数,单位是px,4:3 是最常见屏幕比例 - ![Image text](image/pixel.jpg) - - -- 屏幕像素和图片像素有什么关系 - -``` -在屏幕显示图片时,如果屏幕的长宽比、像素数和图片一致,只需要每个屏幕像素用子像素的敏感组合表示出图片上的像素就可以了。 -那如果图片像素数和屏幕像素数不一样呢? - -当图片像素大于屏幕像素时,屏幕也是进行合并显示的。 -比如一张1200W像素的图片,要在300W像素的显示器(长宽比一致)上显示,那么系统就需要将图片像素进行四合一计算然后再显示。 -当图片像素数大于屏幕像素数时,高像素图片和低像素图片的显示精细度是一样的! -``` - -- 在godot中,一般position的1个单位长度等于1个图片像素 - -# 2. 屏幕坐标 +# 4. 屏幕坐标 ![Image text](image/坐标系.png) ![Image text](image/坐标系-godot-1.png) @@ -77,7 +90,7 @@ unity的2d坐标系虽然在左下角,但是unity的屏幕坐标系依然在 - 相对坐标系:又称为局部坐标系或者本地坐标系,相对于父节点的坐标,godot的坐标都是相对坐标 - 屏幕坐标:屏幕的左上角为坐标系原点 -# 3. 全局和相对坐标的相互转化 +# 5. 全局和相对坐标的相互转化 - 全局坐标和局部坐标(相对坐标)可以相互转化 @@ -89,6 +102,16 @@ Node2D及其子节点的位置可以使用position和gloabl_position来控制。 需要注意的是,全局位置是以场景的左上角为原点的,并不是以根结点的位置作为原点的 ``` +``` +# 坐标点测试用例 +func positionTest(): + print(position) + print(global_position) + print(to_global(position)) + print(to_local(global_position)) + pass +``` + # 4. 场景和节点 ![Image text](image/场景.png) diff --git a/project.godot b/project.godot index 4e96d09..2808d31 100644 --- a/project.godot +++ b/project.godot @@ -24,6 +24,11 @@ config/name="godot-start" run/main_scene="res://scene/demo01_hello/hello_world.tscn" config/icon="res://icon.png" +[display] + +window/stretch/mode="2d" +window/stretch/aspect="keep" + [input] move_left={