Unify examples structure (#1118)

* Animations, CameraAndViewport, CollisionDetection and Components unified

* Added descriptions to effects

* Rename input games

* Unify input stories

* Add info to parallax section

* Added descriptions to the rendering examples

* Add descriptions to the sprites directory

* Fix utils and rendering section

* Add descriptions to the widgets section

* Delete directory that rebase brought back

* Unify game names

* Added some styleguide docs for examples

* Fix analyze issues

* All files should have _example as suffix

* Made the FollowComponentExample a bit easier to understand

* Change priority of ember
This commit is contained in:
Lukas Klingsbo
2021-11-19 14:28:04 +01:00
committed by GitHub
parent 904481d289
commit 8b132d7c0b
90 changed files with 1574 additions and 1140 deletions

View File

@ -0,0 +1,76 @@
import 'dart:math';
import 'package:flame/effects.dart';
import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flame/input.dart';
import 'package:flutter/material.dart';
import '../../commons/square_component.dart';
final green = Paint()..color = const Color(0xAA338833);
final red = Paint()..color = const Color(0xAA883333);
final orange = Paint()..color = const Color(0xAABB6633);
class InfiniteEffectExample extends FlameGame with TapDetector {
static const String description = '''
In this example we show how effects can run in infinity with the
`isInfinite: true` argument. Click on the screen to start the effects.
''';
late SquareComponent greenSquare;
late SquareComponent redSquare;
late SquareComponent orangeSquare;
@override
Future<void> onLoad() async {
await super.onLoad();
SquareComponent makeSquare(Paint paint) {
return SquareComponent(position: Vector2.all(100), paint: paint);
}
add(greenSquare = makeSquare(green));
add(redSquare = makeSquare(red));
add(orangeSquare = makeSquare(orange));
}
@override
void onTapUp(TapUpInfo info) {
final p = info.eventPosition.game;
greenSquare.clearEffects();
redSquare.clearEffects();
orangeSquare.clearEffects();
greenSquare.add(
MoveEffect(
path: [p],
speed: 250.0,
curve: Curves.bounceInOut,
isInfinite: true,
isAlternating: true,
),
);
redSquare.add(
SizeEffect(
size: p,
speed: 250.0,
curve: Curves.easeInCubic,
isInfinite: true,
isAlternating: true,
),
);
orangeSquare.add(
RotateEffect(
angle: (p.x + p.y) % (2 * pi),
speed: 1.0, // Radians per second
curve: Curves.easeInOut,
isInfinite: true,
isAlternating: true,
),
);
}
}