以下代码呈现一个 sprite
和一个带有 alpha 的 solid
。但是 solid
呈现在 sprite
下方。如何让实体呈现在 sprite
上方?
def tick args
args.outputs.sprites << {
x: 100,
y: 100,
w: 50,
h: 60,
path: 'sprites/square-red.png'
}
args.outputs.solids << {
x: 0,
y: 0,
w: 1280,
h: 720,
r: 80,
g: 80,
b: 80,
a: 128
}
end
最佳答案
基元的默认渲染顺序(从最底部到最顶部)是:
实体
Sprite
原语
标签
行数
边框
要在 sprite
上呈现 solid
,您必须使用 args.outputs.primitives
,它将按照您添加的顺序呈现到集合(无论原始类型如何):
def tick args
# step 1: use .primitives instead of .sprites
args.outputs.primitives << {
x: 100,
y: 100,
w: 50,
h: 60,
path: 'sprites/square-red.png'
}.sprite # step 2: invoke the .sprite function on the primitive
# step 3: use .primitives instead of .solids
args.outputs.primitives << {
x: 0,
y: 0,
w: 1280,
h: 720,
r: 80,
g: 80,
b: 80,
a: 128
}.solids # step 4: mark the primitive as a solid
end
这引出了一个问题:
Should I use
.primitives
for everything?
坦率地说,这完全没问题。
关于dragonruby-game-toolkit - 如何在 DragonRuby Game Toolkit 中获取 `solid` 来渲染 `sprite`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63527128/