粒子效果
在本章中,您将会学习到:
- 粒子效果的声明
- 在
Note
原型中使用粒子效果
粒子效果
就像皮肤精灵一样,我们需要通过引用它们的名字来声明我们想要访问的粒子效果。
class Effects {
public:
int note = 0;
}Effects;
auto particles = defineParticles<class Effects>({
{ ParticleEffectName.NoteCircularTapCyan, Effects.note }
});
保存后,将 ParticleData
和 ParticleTexture
复制到 /dist
目录下,重新编译引擎后,Sonolus.h 会自动将粒子效果上传至服务器。
音符
为了在判定时添加粒子效果,我们需要使用 SpawnParticleEffect
来播放粒子效果。
让我们将我们的粒子效果设为音符的两倍大小,持续 0.3
秒,并且不循环:
class Note: public Archetype {
// ...
SonolusApi touch() {
FUNCBEGIN
// ...
FOR (i, 0, touches.size, 1) {
// ...
let l = -1 * note.radius, r = note.radius;
let b = judgeLine.y - note.radius, t = judgeLine.y + note.radius;
SpawnParticleEffect(Effects.note, l, b, l, t, r, t, r, b, 0.3, false);
// ...
} DONE
return VOID;
}
// ...
};