fix Particles not being drawn with the new image member

This commit is contained in:
Kae 2023-06-26 02:03:50 +10:00
parent 500e81329a
commit 79c5012033
3 changed files with 13 additions and 8 deletions

View File

@ -42,6 +42,7 @@ Particle::Particle() {
length = 0;
destructionAction = DestructionAction::None;
destructionTime = 0.0f;
destructionSet = false;
trail = false;
flippable = true;
flip = false;
@ -224,13 +225,16 @@ void Particle::destructionUpdate() {
} else if (destructionAction == DestructionAction::Fade) {
color.setAlphaF(destructionFactor);
} else if (destructionAction == DestructionAction::Image) {
size = 1.0f;
color = Color::White;
type = Particle::Type::Textured;
image = destructionImage;
angularVelocity = 0.0f;
length = 0.0f;
rotation = 0.0f;
if (!destructionSet) {
size = 1.0f;
color = Color::White;
type = Particle::Type::Textured;
image = destructionImage;
angularVelocity = 0.0f;
length = 0.0f;
rotation = 0.0f;
destructionSet = true;
}
}
}
}

View File

@ -100,6 +100,7 @@ struct Particle {
DestructionAction destructionAction;
AssetPath destructionImage;
float destructionTime;
bool destructionSet;
float timeToLive;
Layer layer;

View File

@ -182,7 +182,7 @@ void WorldPainter::renderParticles(WorldRenderData& renderData, Particle::Layer
} else if (particle.type == Particle::Type::Textured || particle.type == Particle::Type::Animated) {
Drawable drawable;
if (particle.type == Particle::Type::Textured)
drawable = Drawable::makeImage(particle.string, 1.0f / TilePixels, true, Vec2F(0, 0));
drawable = Drawable::makeImage(particle.image, 1.0f / TilePixels, true, Vec2F(0, 0));
else
drawable = particle.animation->drawable(1.0f / TilePixels);