Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComponentParticle fails with CircleComponent #2962

Open
ufrshubham opened this issue Jan 6, 2024 · 1 comment
Open

ComponentParticle fails with CircleComponent #2962

ufrshubham opened this issue Jan 6, 2024 · 1 comment
Labels

Comments

@ufrshubham
Copy link
Collaborator

Current bug behavior

When using a CircleComponent with ComponentParticle, an exceptions gets raised for CircleComponent._centerOffset not being initialized. This happens because components added to ComponentParticle are not really part of the component tree. This mean they never get correctly loaded and mounted. ComponentParticle only makes sure to invoke the render and update method of the component that it encapsulates, essentially skipping all the standard component lifecycle processing.

Expected behavior

CircleComponent, should work with ComponentParticle. Ideally any kind of component should working with ComponentParticle.

Steps to reproduce

Adding following code to any game should reproduce the problem.

await add(
  ParticleSystemComponent(
    particle: ComponentParticle(component: CircleComponent(radius: 2)),
  ),
);

Flutter doctor output

Output of: flutter doctor -v

N.A.

More environment information

Flame version: 1.14.0
Platform affected: All

Log information

════════ Exception caught by rendering library ═════════════════════════════════
The following LateError was thrown during paint():
LateInitializationError: Field '_centerOffset@1199492026' has not been initialized.

More information

I can only think of converting the Particle class into a Component to make it work properly for all components. This sounds like a big change and I probably won't have enough time to working on this, so reporting this issue.

But there are more such component-like classes which I think need to be streamlined. EffectController is one such example where they need to be ticked every frame.

@ufrshubham ufrshubham added the bug label Jan 6, 2024
@spydon
Copy link
Member

spydon commented Jan 6, 2024

Hmm, good catch. I don't think we'd want to convert particle to a real component since they are much heavier and you might have thousands of particles. Not sure what a good solution here could be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants