New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不是太理解 in out 这些参数的含义。 #4
Comments
in 用来读,out 用来写。你 select out 后读的值是未定义的。 |
感谢。我看了一下可以附加的选项有 表示用途的: 表示条件的: new 又有什么含义呢。 |
另,在您的blog 里面看到可打 tag, 似乎未看到有api |
new 用来创建新的 component ,但是有限制:在 select 之前,该类 component 一个都不存在,select 过程中,依次创建出来。 tag 就是一种特殊的 component ,所以可以用 out 写入,看作是一个 boolean 。可以用 exist absent 在 select 中筛选。 |
抱歉,对 C 不熟。 local ecs = require "ecs"
local w = ecs.world()
w:register {
name = "value",
type = "int",
}
w:register {
name = "mark"
}
w:new {
value = 1,
mark = true,
}
w:new {
mark = true,
}
for v in w:select "mark" do
w:sync("value?in", v)
print(v.value)
end
for v in w:select "mark" do
print(pcall(w.sync, w, "value:in", v))
end
而我用 w:select 'mark:exists' 所得到的应只是一个 {component pool index, component id} 这样的结构,设计上是否就是让 TAG 返回索引,然后用 sync 来将数据读取出来。 _sync 与 _read 的差别是什么?(对 C 真不熟悉) |
你如果想 select 包含 mark 这个 tag 且读出 value 字段 ,应该用 sync 是一个补充手段,一般用 select 就可以完成绝大部分功能。 |
这个有什么内在含义,为何会有不同的结果。
The text was updated successfully, but these errors were encountered: