fix: Viewport should recieve events before the world (#2630)

The viewport should receive events before the world, otherwise all huds will get the events after the world components, if there are any world components underneath them.
This commit is contained in:
Lukas Klingsbo
2023-08-07 13:57:21 +02:00
committed by GitHub
parent ff59aa152c
commit e852064e49
7 changed files with 77 additions and 18 deletions

View File

@ -39,7 +39,7 @@ class JoystickAdvancedExample extends FlameGame with HasCollisionDetection {
columns: 6,
rows: 1,
);
add(ScreenHitbox());
world.add(ScreenHitbox()..anchor = cameraComponent.viewfinder.anchor);
joystick = JoystickComponent(
knob: SpriteComponent(
sprite: sheet.getSpriteById(1),
@ -184,13 +184,13 @@ class JoystickAdvancedExample extends FlameGame with HasCollisionDetection {
),
)..add(directionText);
add(player);
add(joystick);
add(flipButton);
add(flopButton);
add(buttonComponent);
add(spriteButtonComponent);
add(shapeButton);
world.add(player);
cameraComponent.viewport.add(joystick);
cameraComponent.viewport.add(flipButton);
cameraComponent.viewport.add(flopButton);
cameraComponent.viewport.add(buttonComponent);
cameraComponent.viewport.add(spriteButtonComponent);
cameraComponent.viewport.add(shapeButton);
cameraComponent.viewport.add(speedWithMargin);
cameraComponent.viewport.add(directionWithMargin);
}