Files
flame/examples/lib/stories/components/components.dart
DevKage 720c3566b0 feat: Add lookAt method for PositionComponent (#1891)
This PR adds a new method called lookAt for PositionComponent. It is a convenience method which rotates the component to make it point towards/look at the given target position.

Additionally, this PR also adds a angleTo method which can be used to get the calculated angle for lookAt. It will be useful if someone want to smoothly rotate towards target using effects or manual lerping.
2022-09-18 20:57:07 +02:00

57 lines
2.0 KiB
Dart

import 'package:dashbook/dashbook.dart';
import 'package:examples/commons/commons.dart';
import 'package:examples/stories/components/clip_component_example.dart';
import 'package:examples/stories/components/composability_example.dart';
import 'package:examples/stories/components/debug_example.dart';
import 'package:examples/stories/components/game_in_game_example.dart';
import 'package:examples/stories/components/look_at_example.dart';
import 'package:examples/stories/components/look_at_smooth_example.dart';
import 'package:examples/stories/components/priority_example.dart';
import 'package:flame/game.dart';
void addComponentsStories(Dashbook dashbook) {
dashbook.storiesOf('Components')
..add(
'Composability',
(_) => GameWidget(game: ComposabilityExample()),
codeLink: baseLink('components/composability_example.dart'),
info: ComposabilityExample.description,
)
..add(
'Priority',
(_) => GameWidget(game: PriorityExample()),
codeLink: baseLink('components/priority_example.dart'),
info: PriorityExample.description,
)
..add(
'Debug',
(_) => GameWidget(game: DebugExample()),
codeLink: baseLink('components/debug_example.dart'),
info: DebugExample.description,
)
..add(
'Game-in-game',
(_) => GameWidget(game: GameInGameExample()),
codeLink: baseLink('components/game_in_game_example.dart'),
info: GameInGameExample.description,
)
..add(
'ClipComponent',
(context) => GameWidget(game: ClipComponentExample()),
codeLink: baseLink('components/clip_component_example.dart'),
info: ClipComponentExample.description,
)
..add(
'Look At',
(_) => GameWidget(game: LookAtExample()),
codeLink: baseLink('components/look_at_example.dart'),
info: LookAtExample.description,
)
..add(
'Look At Smooth',
(_) => GameWidget(game: LookAtSmoothExample()),
codeLink: baseLink('components/look_at_smooth_example.dart'),
info: LookAtExample.description,
);
}