diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2025-01-10 16:26:05 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2025-01-10 16:26:05 +0100 |
commit | a981a42a7378ed51155590215557e52553031272 (patch) | |
tree | 7ca1b0cb7f72d6e8d50df09470a177a09ee12e51 /game/missile/SpawnEvent.cpp | |
parent | 0f8bf257d86b5532f3d6f559e5368668c255af7c (diff) |
missile solution, cannot find @max issue
Diffstat (limited to 'game/missile/SpawnEvent.cpp')
-rw-r--r-- | game/missile/SpawnEvent.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/game/missile/SpawnEvent.cpp b/game/missile/SpawnEvent.cpp index c7209b7..6109686 100644 --- a/game/missile/SpawnEvent.cpp +++ b/game/missile/SpawnEvent.cpp @@ -20,16 +20,17 @@ void MissileSpawnEventHandler::init() { } bool MissileSpawnEventHandler::on_event(const MissileSpawnEvent & event) { - auto missile_transforms = this->get_components_by_name<Transform>("missile"); auto alert_sprites = this->get_components_by_name<Sprite>("missile_alert"); - auto alert_transforms = this->get_components_by_name<Transform>("missile_alert"); + + auto missile_transforms = this->get_components_by_name<Transform>("missile"); auto colliders = this->get_components_by_name<CircleCollider>("missile"); auto missile_behaviorscripts = this->get_components_by_name<BehaviorScript>("missile"); auto missile_audiosources = this->get_components_by_name<AudioSource>("missile"); + auto & camera_transform = this->get_components_by_name<Transform>("camera").front().get(); - for (size_t i = 0; i < missile_behaviorscripts.size(); ++i) { - auto & script = missile_behaviorscripts[i * 2].get(); + for (size_t i = 0; i < missile_transforms.size(); ++i) { + BehaviorScript & script = missile_behaviorscripts[i * 2].get(); if (script.active) continue; script.active = true; colliders[i].get().active = true; @@ -39,7 +40,6 @@ bool MissileSpawnEventHandler::on_event(const MissileSpawnEvent & event) { transform.position.x = camera_transform.position.x + this->MISSILE_OFFSET; transform.position.y = Random::i(this->MAX_RANGE, this->MIN_RANGE); - auto & alert_transform = alert_transforms[i].get(); auto & alert_sprite = alert_sprites[i].get(); alert_sprite.active = true; break; |