Outdated example : Zoom , Coordinate System
What could be improved
Currently the example codes doesn't account for current version of 🔥 flame engine (1.0.0) where ScaleUpdateInfo where the property delta is not present
I haven't used flame engine long enough to know the api's but either this has been removed intentionally or mistakenly but either way the example should be updated appropriately.
Example - Zoom page https://github.com/flame-engine/flame/blob/6e66baa12fdad7b27f35ca274433acd55165f106/examples/lib/stories/camera_and_viewport/zoom_example.dart#L55-L63
Coordinate Example Page -
The coordinate page always has delta empty for some reason while the zoom page works
What it is currently
Current implementation doesn't have any similar property from what I can tell (please do let me know if there is one) but either way the code should be updated for the current version
For zoom example A migration could be as simple as setting a field as we do for zoom variable anyway
class ZoomExample extends FlameGame with ScrollDetector, ScaleDetector {
....
Vector2 startScalePosition;
....
@override
void onScaleStart(ScaleStartInfo info) {
startPosition = info.eventPosition.game;
startZoom = camera.zoom;
}
@override
void onScaleUpdate(ScaleUpdateInfo info) {
final currentScale = info.scale.global;
if (!currentScale.isIdentity()) {
camera.zoom = startZoom * currentScale.y;
clampZoom();
} else {
camera.translateBy(startScalePosition - info.eventPosition.game);
camera.snap();
}
}
I am ommiting the environment details from the report as they are not required
What are the risks
Well people who are new to flutter and flame will be very confused why is the example is not working on their own code.
You are looking at the example that is for main, the example that is for 1.0.0 is under the 1.0.0 tag so it can be found here:
https://github.com/flame-engine/flame/blob/1.0.0/examples/lib/stories/camera_and_viewport/zoom_example.dart
@spydon oh right... i was redirected there from the https://examples.flame-engine.org/#/ page using the code button on the right so I assumed that was the correct one.
Yeah, we should probably build something similar to the version selector that we have on the docs to make it less confusing.