generateValues not being triggered[Bug]:
arnovanzyl opened this issue · 2 comments
arnovanzyl commented
What happened?
It seems that with version 3.0.9 the generateValues function is no longer being triggered.
Steps to reproduce?
import 'package:bonfire/bonfire.dart';
import 'package:flame_audio/flame_audio.dart';
import 'package:get/get.dart';
import 'package:platformer/characters/player/common_sprite_sheet.dart';
import 'package:platformer/services/user_settings_service/service/user_settings_service.dart';
class PotionLife extends GameDecoration
with Sensor<Player>, Movement, HandleForces, BlockMovementCollision {
final double life;
double _lifeDistributed = 0;
PotionLife(Vector2 position, this.life, {Vector2? size})
: super.withAnimation(
animation: CommonSpriteSheet.potionLifeSprite,
position: position,
size: size ?? Vector2.all(8),
);
@override
void onContact(Player component) {
generateValues(
const Duration(seconds: 1),
onChange: (value) {
if (_lifeDistributed < life) {
double newLife = life * value - _lifeDistributed;
_lifeDistributed += newLife;
component.addLife(newLife.roundToDouble());
}
},
);
UserSettingsService userSettingsService = Get.find();
FlameAudio.play(
'effects/pickup_sound.wav',
volume: userSettingsService.userSettings.value.effectVolume,
);
removeFromParent();
super.onContact(component);
}
@override
Future<void> onLoad() {
renderAboveComponents = true;
priority = 3;
debugMode = false;
add(
RectangleHitbox(
size: Vector2(size.x, size.y),
anchor: Anchor.topLeft,
isSolid: true,
),
);
return super.onLoad();
}
}
What did you expect to happen?
In version 3.0.6 the following game object worked, however since then it seems that the generateValues function is no longer being triggered
Bonfire version
Release 3.0.9
Relevant log output
No response
RafaelBarbosatec commented
Fixed in version 3.0.10
Please use gameRef. generateValues
when you need remove the current component.
When you use generateValues
, it will be removed together with component.
arnovanzyl commented
Thanks Rafael!!! Always appreciate the brilliant work! 🥳😁