Parallax docs examples use baseSpeed, fromParallax and other APIs that don't exist

Abierto Apto para principiantes
#4,219 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
91/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
dart, flutter

Línea de trabajo

Abre doc/flame/components/parallax_component.md y compara los dos ejemplos con las referencias de API en packages/flame/lib/src/parallax.dart y parallax_component.dart, además de examples/lib/stories/parallax/advanced_parallax_example.dart. Actualiza los ejemplos para que usen las API y las formas documentadas. El trabajo estará terminado cuando ambos ejemplos compilen al copiarlos y ya no hagan referencia a API inexistentes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What could be improved

Two examples in the Parallax docs (doc/flame/components/parallax_component.md, on main at 88c0438) use APIs that don't exist or have a different shape, so they don't compile when copied.

Runtime-update example (lines 66-75):

  • The text and code use baseSpeed, but the mutable field on Parallax is baseVelocity (packages/flame/lib/src/parallax.dart:441).
  • parallax.velocityMultiplierDelta = ... assigns a property that doesn't exist. velocityMultiplierDelta is only a Parallax.load argument (parallax.dart:514) used to set each layer's velocityMultiplier.
  • parallaxComponent.parallax is Parallax? (parallax_component.dart:71), so it needs a ! before use.

Advanced example (lines 108-120):

  • await image sits inside the images.map callback, which isn't async.
  • velocityMultiplier: images.indexOf(image) * 2.0 passes a double, but the parameter is Vector2? (parallax.dart:243).
  • ParallaxComponent.fromParallax(...) doesn't exist; the constructor is ParallaxComponent(parallax: ...), as examples/lib/stories/parallax/advanced_parallax_example.dart uses.

None of baseSpeed, layerDelta or fromParallax is defined anywhere in packages/flame/lib.

Why should this be improved

These are the examples people copy when they first set up a parallax, and each of them fails at compile time.

Risks

Docs only, no API change.

More information

The fix is small, about 8 lines in that one file: rename baseSpeed to baseVelocity in the text and code, drop the velocityMultiplierDelta assignment, use parallaxComponent.parallax!, mark the map callback async, pass Vector2(images.indexOf(image) * 2.0, 1.0), and use ParallaxComponent(parallax: Parallax(...)). Happy to send a PR once you're fine with it.

Prepared with AI assistance (Claude Code).

Other
  • Are you interested in working on a PR for this?
Lenguaje dominante
Dart
Estrellas
10.8k
Forks
1.1k
Merge medio
1 d 19 h
PR fusionados (30 d)
54

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de flame-engine/flame

Todos los issues de flame-engine/flame

Issues similares

Más issues de Dart

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.