pull/2/head
jaysunxiao 2022-05-18 21:08:42 +08:00
parent 9eb992ef76
commit d422c6bdab
12 changed files with 158 additions and 121 deletions

View File

@ -12,4 +12,6 @@
### 4.安装和HelloWorld
- 建议再看看底61集的视频学会调整运行时候的屏幕位置避免运行时候屏幕位置出现问题
- 建议再看看底61集的视频黑白控制台是否隐藏学会调整运行时候的屏幕位置避免运行时候屏幕位置出现问题
- fix纠正P25说的深度优先遍历顺序绘制节点的顺序应该是广度优先遍历

View File

@ -56,7 +56,7 @@ CTRL + Z ,撤销上一步操作
- 在2D画面中两个对象如果重叠谁显示在上面呢
- 按照节点的顺序
- 在数据结构上的专业术语叫树的深度优先遍历,深度优先遍历的顺序就是最后显示的顺序
- 在数据结构上的专业术语叫树的广度优先遍历,广度优先遍历的顺序就是最后显示的顺序
![Image text](../demo05_scene_node/image/节点.png)
![Image text](../demo05_scene_node/image/节点渲染顺序.png)

View File

@ -62,7 +62,7 @@ func _process(delta):
- Canvas是画布的意思所以CanvasItem代表了就是可以被绘制节点可以设置可视化界面和材质的颜色
- 所有的2D节点和GUI节点都继承于CanvasItem节点
- CanvasItem是按树的树的度优先遍历顺序绘制的
- CanvasItem是按树的树的广度优先遍历顺序绘制的
- 可以通过设置CanvasItem的Show Behind Parent来改变最终渲染到屏幕上的画面顺序
```

View File

@ -18,6 +18,7 @@
- 图片像素
![Image text](image/pixel.jpg)
@ -45,11 +46,10 @@
# 3. 垂直同步
- Vsync垂直同步
- Vsync垂直同步又称场同步Vertical Hold
```
垂直同步又称场同步Vertical Hold从CRT显示器的显示原理来看单个像素组成了水平扫描线水平扫描线在垂直方向的堆积形成了完整的画面。
显示器的刷新率受显卡DAC控制显卡DAC完成一帧的扫描后就会产生一个垂直同步信号。
我们平时所说的打开垂直同步指的是将该信号送入显卡3D图形处理部分从而让显卡在生成3D图形时受垂直同步信号的制约。
当我们选择"等待垂直同步信号"即打开垂直同步显卡绘制3D图形前会等待垂直同步信号
@ -66,6 +66,33 @@
![Image text](image/window03.jpg)
- CRT显示器学名为“阴极射线显像管”是一种使用阴极射线管Cathode Ray Tube的显示器。
```
屏幕上的图形图像是由一个个因电子束击打而发光的荧光点组成
电子枪从屏幕的左上角的第一行(行的多少根据显示器当时的分辨率所决定比如800X600分辨率下电子枪就要扫描600行)开始,从左至右逐行扫描,
第一行扫描完后再从第二行的最左端开始至第二行的最右端,一直到扫描完整个屏幕后再从屏幕的左上角开始,这时就完成了一次对屏幕的刷新,周而复始。
从CRT显示器的显示原理来看单个像素组成了水平扫描线水平扫描线在垂直方向的堆积形成了完整的画面。
显示器的刷新率受显卡DAC控制显卡DAC完成一帧的扫描后就会产生一个垂直同步信号。
```
- 液晶显示器借助于薄膜晶体管驱动的有源矩阵液晶显示器,它主要是以电流刺激液晶分子产生点、线、面配合背部灯管构成画面。
```
在电场的作用下,利用液晶分子的排列方向发生变化,使外光源透光率改变(调制),完成电一光变换,
再利用R、G、B三基色信号的不同激励通过红、绿、蓝三基色滤光膜完成时域和空间域的彩色重显。
LCD的刷新率与CRT不同因为LCD和CRT的显像方式不同CRT是靠不断刷新画面来使显示器显示图像的而LCD只要改变发光颗粒就能使显示器中的画面动起来
正是由于LCD与CRT显像方式不同LCD显示器本身不会出现屏幕闪烁的现象
打开垂直同步可以使得画面平滑、稳定。
关闭垂直同步,则可以明显提高帧数,获得更快的速度,代价就是牺牲稳定性,显卡持续高负荷运转势必发热,进而影响计算速度。
```
# 4. 屏幕坐标
![Image text](image/坐标系.png)
@ -112,20 +139,22 @@ func positionTest():
pass
```
# 4. 场景和节点
# 6. 深度遍历显示节点
![Image text](image/场景.png)
![Image text](image/节点.png)
![Image text](image/节点渲染顺序.png)
![Image text](image/节点的顺序.png)
- 一个游戏可以包含多个场景但是一个场景中必须有一个根节点一个根节点可以包含多个不重名的子节点unity的子节点可以同名不同名更加符合习惯为godot点赞。
# 5. 基本组件
- fix纠正P25说的深度优先遍历顺序绘制节点的顺序应该是广度优先遍历
# 7. Image类的使用
- CanvasItem节点CanvasItem -> Node -> Object
- Canvas是画布的意思所以CanvasItem代表了就是可以被绘制节点可以设置可视化界面和材质的颜色
- 所有的2D节点和GUI节点都继承于CanvasItem节点
![Image text](image/节点的顺序.png)
![Image text](./image/component1.png)

View File

@ -258,12 +258,12 @@ func readPacket(protocolId):
func newInstance(protocolId: int):
return ProtocolManager.newInstance(protocolId)
func writeBooleanArray(value):
if (value == null):
func writeBooleanArray(array):
if (array == null):
writeInt(0)
else:
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
writeBool(element)
func readBooleanArray():
@ -274,12 +274,12 @@ func readBooleanArray():
array.append(readBool())
return array
func writeByteArray(value):
if (value == null):
func writeByteArray(array):
if (array == null):
writeInt(0)
else:
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
writeByte(element)
func readByteArray():
@ -290,12 +290,12 @@ func readByteArray():
array.append(readByte())
return array
func writeShortArray(value):
if (value == null):
func writeShortArray(array):
if (array == null):
writeInt(0)
else:
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
writeShort(element)
func readShortArray():
@ -306,12 +306,12 @@ func readShortArray():
array.append(readShort())
return array
func writeIntArray(value):
if (value == null):
func writeIntArray(array):
if (array == null):
writeInt(0)
else:
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
writeInt(element)
func readIntArray():
@ -322,12 +322,12 @@ func readIntArray():
array.append(readInt())
return array
func writeLongArray(value):
if (value == null):
func writeLongArray(array):
if (array == null):
writeInt(0)
else:
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
writeLong(element)
func readLongArray():
@ -338,12 +338,12 @@ func readLongArray():
array.append(readLong())
return array
func writeFloatArray(value):
if (value == null):
func writeFloatArray(array):
if (array == null):
writeInt(0)
else:
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
writeFloat(element)
func readFloatArray():
@ -354,12 +354,12 @@ func readFloatArray():
array.append(readFloat())
return array
func writeDoubleArray(value):
if (value == null):
func writeDoubleArray(array):
if (array == null):
writeInt(0)
else:
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
writeDouble(element)
func readDoubleArray():
@ -370,12 +370,12 @@ func readDoubleArray():
array.append(readDouble())
return array
func writeCharArray(value):
if (value == null):
func writeCharArray(array):
if (array == null):
writeInt(0)
else:
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
writeChar(element)
func readCharArray():
@ -386,12 +386,12 @@ func readCharArray():
array.append(readChar())
return array
func writeStringArray(value):
if (value == null):
func writeStringArray(array):
if (array == null):
writeInt(0)
else:
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
writeString(element)
func readStringArray():
@ -403,13 +403,13 @@ func readStringArray():
return array
func writePacketArray(value, protocolId):
if (value == null):
func writePacketArray(array, protocolId):
if (array == null):
writeInt(0)
else:
var protocolRegistration = ProtocolManager.getProtocol(protocolId)
writeInt(value.size());
for element in value:
writeInt(array.size());
for element in array:
protocolRegistration.write(self, element)
func readPacketArray(protocolId):
@ -421,14 +421,14 @@ func readPacketArray(protocolId):
array.append(protocolRegistration.read(self))
return array
func writeIntIntMap(value):
if (value == null):
func writeIntIntMap(map):
if (map == null):
writeInt(0)
else:
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeInt(key)
writeInt(value[key])
writeInt(map[key])
func readIntIntMap():
var map = {}
@ -440,14 +440,14 @@ func readIntIntMap():
map[key] = value
return map
func writeIntLongMap(value):
if (value == null):
func writeIntLongMap(map):
if (map == null):
writeInt(0)
else:
writeInt(value.size())
for key in value:
writeInt(key)
writeLong(value[key])
writeInt(map.size())
for key in map:
writeInt(map)
writeLong(map[key])
func readIntLongMap():
var map = {}
@ -459,14 +459,14 @@ func readIntLongMap():
map[key] = value
return map
func writeIntStringMap(value):
if (value == null):
func writeIntStringMap(map):
if (map == null):
writeInt(0)
else:
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeInt(key)
writeString(value[key])
writeString(map[key])
func readIntStringMap():
var map = {}
@ -479,15 +479,15 @@ func readIntStringMap():
return map
func writeIntPacketMap(value, protocolId):
if (value == null):
func writeIntPacketMap(map, protocolId):
if (map == null):
writeInt(0)
else:
var protocolRegistration = ProtocolManager.getProtocol(protocolId)
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeInt(key)
protocolRegistration.write(self, value[key])
protocolRegistration.write(self, map[key])
func readIntPacketMap(protocolId):
var map = {}
@ -501,14 +501,14 @@ func readIntPacketMap(protocolId):
return map
func writeLongIntMap(value):
if (value == null):
func writeLongIntMap(map):
if (map == null):
writeInt(0)
else:
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeLong(key)
writeInt(value[key])
writeInt(map[key])
func readLongIntMap():
var map = {}
@ -520,14 +520,14 @@ func readLongIntMap():
map[key] = value
return map
func writeLongLongMap(value):
if (value == null):
func writeLongLongMap(map):
if (map == null):
writeInt(0)
else:
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeLong(key)
writeLong(value[key])
writeLong(map[key])
func readLongLongMap():
var map = {}
@ -539,14 +539,14 @@ func readLongLongMap():
map[key] = value
return map
func writeLongStringMap(value):
if (value == null):
func writeLongStringMap(map):
if (map == null):
writeInt(0)
else:
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeLong(key)
writeString(value[key])
writeString(map[key])
func readLongStringMap():
var map = {}
@ -559,15 +559,15 @@ func readLongStringMap():
return map
func writeLongPacketMap(value, protocolId):
if (value == null):
func writeLongPacketMap(map, protocolId):
if (map == null):
writeInt(0)
else:
var protocolRegistration = ProtocolManager.getProtocol(protocolId)
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeLong(key)
protocolRegistration.write(self, value[key])
protocolRegistration.write(self, map[key])
func readLongPacketMap(protocolId):
var map = {}
@ -581,14 +581,14 @@ func readLongPacketMap(protocolId):
return map
func writeStringIntMap(value):
if (value == null):
func writeStringIntMap(map):
if (map == null):
writeInt(0)
else:
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeString(key)
writeInt(value[key])
writeInt(map[key])
func readStringIntMap():
var map = {}
@ -600,14 +600,14 @@ func readStringIntMap():
map[key] = value
return map
func writeStringLongMap(value):
if (value == null):
func writeStringLongMap(map):
if (map == null):
writeInt(0)
else:
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeString(key)
writeLong(value[key])
writeLong(map[key])
func readStringLongMap():
var map = {}
@ -619,14 +619,14 @@ func readStringLongMap():
map[key] = value
return map
func writeStringStringMap(value):
if (value == null):
func writeStringStringMap(map):
if (map == null):
writeInt(0)
else:
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeString(key)
writeString(value[key])
writeString(map[key])
func readStringStringMap():
var map = {}
@ -639,15 +639,15 @@ func readStringStringMap():
return map
func writeStringPacketMap(value, protocolId):
if (value == null):
func writeStringPacketMap(map, protocolId):
if (map == null):
writeInt(0)
else:
var protocolRegistration = ProtocolManager.getProtocol(protocolId)
writeInt(value.size())
for key in value:
writeInt(map.size())
for key in map:
writeString(key)
protocolRegistration.write(self, value[key])
protocolRegistration.write(self, map[key])
func readStringPacketMap(protocolId):
var map = {}

View File

@ -3,6 +3,7 @@
#
# @author jaysunxiao
# @version 3.0
# byte类型最简单的整形
var a # byte
# byte的包装类型
@ -206,7 +207,7 @@ static func write(buffer, packet):
static func read(buffer):
if (!buffer.readBool()):
return null
var packet = buffer.newInstance(100)
var packet = buffer.newInstance(PROTOCOL_ID)
var result19 = buffer.readByte()
packet.a = result19
var result20 = buffer.readByte()

View File

@ -1,5 +1,6 @@
# @author jaysunxiao
# @version 3.0
var a # byte
var aaa # byte[]
var b # short
@ -47,7 +48,7 @@ static func write(buffer, packet):
static func read(buffer):
if (!buffer.readBool()):
return null
var packet = buffer.newInstance(101)
var packet = buffer.newInstance(PROTOCOL_ID)
var result0 = buffer.readByte()
packet.a = result0
var array1 = buffer.readByteArray()

View File

@ -1,5 +1,6 @@
# @author jaysunxiao
# @version 3.0
var a # int
var m # java.util.Map<java.lang.Integer, java.lang.String>
var objectB # com.zfoo.protocol.packet.ObjectB
@ -17,7 +18,7 @@ static func write(buffer, packet):
static func read(buffer):
if (!buffer.readBool()):
return null
var packet = buffer.newInstance(102)
var packet = buffer.newInstance(PROTOCOL_ID)
var result0 = buffer.readInt()
packet.a = result0
var map1 = buffer.readIntStringMap()

View File

@ -1,5 +1,6 @@
# @author jaysunxiao
# @version 3.0
var flag # boolean
const PROTOCOL_ID = 103
@ -13,7 +14,7 @@ static func write(buffer, packet):
static func read(buffer):
if (!buffer.readBool()):
return null
var packet = buffer.newInstance(103)
var packet = buffer.newInstance(PROTOCOL_ID)
var result0 = buffer.readBool()
packet.flag = result0
return packet

View File

@ -1,5 +1,6 @@
# @author jaysunxiao
# @version 3.0
var c # int
var g # boolean
@ -15,7 +16,7 @@ static func write(buffer, packet):
static func read(buffer):
if (!buffer.readBool()):
return null
var packet = buffer.newInstance(104)
var packet = buffer.newInstance(PROTOCOL_ID)
var result0 = buffer.readInt()
packet.c = result0
var result1 = buffer.readBool()

View File

@ -92,6 +92,7 @@ func test():
var newByteBuffer = ByteBuffer.new()
ProtocolManager.write(newByteBuffer, packet);
print(newByteBuffer.getWriteOffset())
var newPacket = ProtocolManager.read(newByteBuffer);
print(newPacket)