mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
Reverting doc rename
This commit is contained in:
70
doc/examples/debug/.gitignore
vendored
Normal file
70
doc/examples/debug/.gitignore
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Visual Studio Code related
|
||||
.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.packages
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
|
||||
# Android related
|
||||
**/android/**/gradle-wrapper.jar
|
||||
**/android/.gradle
|
||||
**/android/captures/
|
||||
**/android/gradlew
|
||||
**/android/gradlew.bat
|
||||
**/android/local.properties
|
||||
**/android/**/GeneratedPluginRegistrant.java
|
||||
|
||||
# iOS/XCode related
|
||||
**/ios/**/*.mode1v3
|
||||
**/ios/**/*.mode2v3
|
||||
**/ios/**/*.moved-aside
|
||||
**/ios/**/*.pbxuser
|
||||
**/ios/**/*.perspectivev3
|
||||
**/ios/**/*sync/
|
||||
**/ios/**/.sconsign.dblite
|
||||
**/ios/**/.tags*
|
||||
**/ios/**/.vagrant/
|
||||
**/ios/**/DerivedData/
|
||||
**/ios/**/Icon?
|
||||
**/ios/**/Pods/
|
||||
**/ios/**/.symlinks/
|
||||
**/ios/**/profile
|
||||
**/ios/**/xcuserdata
|
||||
**/ios/.generated/
|
||||
**/ios/Flutter/App.framework
|
||||
**/ios/Flutter/Flutter.framework
|
||||
**/ios/Flutter/Generated.xcconfig
|
||||
**/ios/Flutter/app.flx
|
||||
**/ios/Flutter/app.zip
|
||||
**/ios/Flutter/flutter_assets/
|
||||
**/ios/ServiceDefinitions.json
|
||||
**/ios/Runner/GeneratedPluginRegistrant.*
|
||||
|
||||
# Exceptions to above rules.
|
||||
!**/ios/**/default.mode1v3
|
||||
!**/ios/**/default.mode2v3
|
||||
!**/ios/**/default.pbxuser
|
||||
!**/ios/**/default.perspectivev3
|
||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
||||
10
doc/examples/debug/.metadata
Normal file
10
doc/examples/debug/.metadata
Normal file
@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: f91df4abe1427fef8862c9e81b2e5af6fc05a67a
|
||||
channel: dev
|
||||
|
||||
project_type: app
|
||||
3
doc/examples/debug/README.md
Normal file
3
doc/examples/debug/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# debug
|
||||
|
||||
A sample Flame game showcasing how to use Flame's debug features and components.
|
||||
11
doc/examples/debug/assets/android.svg
Normal file
11
doc/examples/debug/assets/android.svg
Normal file
@ -0,0 +1,11 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 105">
|
||||
<g fill="#97C024" stroke="#97C024" stroke-linejoin="round" stroke-linecap="round">
|
||||
<path d="M14,40v24M81,40v24M38,68v24M57,68v24M28,42v31h39v-31z" stroke-width="12"/>
|
||||
<path d="M32,5l5,10M64,5l-6,10 " stroke-width="2"/>
|
||||
</g>
|
||||
<path d="M22,35h51v10h-51zM22,33c0-31,51-31,51,0" fill="#97C024"/>
|
||||
<g fill="#FFF">
|
||||
<circle cx="36" cy="22" r="2"/>
|
||||
<circle cx="59" cy="22" r="2"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 471 B |
88
doc/examples/debug/lib/main.dart
Normal file
88
doc/examples/debug/lib/main.dart
Normal file
@ -0,0 +1,88 @@
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flame/flame.dart';
|
||||
import 'package:flame/svg.dart';
|
||||
import 'package:flame/position.dart';
|
||||
import 'package:flame/components/component.dart' show SvgComponent;
|
||||
import 'package:flame/components/mixins/resizable.dart';
|
||||
import 'package:flame/text_config.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() async {
|
||||
await Flame.util.initialDimensions();
|
||||
|
||||
final myGame = MyGame();
|
||||
runApp(myGame.widget);
|
||||
myGame.start();
|
||||
}
|
||||
|
||||
class AndroidComponent extends SvgComponent with Resizable {
|
||||
static const int SPEED = 150;
|
||||
int xDirection = 1;
|
||||
int yDirection = 1;
|
||||
|
||||
AndroidComponent() : super.fromSvg(100, 100, Svg('android.svg'));
|
||||
|
||||
@override
|
||||
void update(double dt) {
|
||||
super.update(dt);
|
||||
if (size == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
x += xDirection * SPEED * dt;
|
||||
|
||||
final rect = toRect();
|
||||
|
||||
if ((x <= 0 && xDirection == -1) ||
|
||||
(rect.right >= size.width && xDirection == 1)) {
|
||||
xDirection = xDirection * -1;
|
||||
}
|
||||
|
||||
y += yDirection * SPEED * dt;
|
||||
|
||||
if ((y <= 0 && yDirection == -1) ||
|
||||
(rect.bottom >= size.height && yDirection == 1)) {
|
||||
yDirection = yDirection * -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyGame extends BaseGame {
|
||||
final fpsTextConfig = const TextConfig(color: const Color(0xFFFFFFFF));
|
||||
|
||||
@override
|
||||
bool debugMode() => true;
|
||||
|
||||
@override
|
||||
bool recordFps() => true;
|
||||
|
||||
void start() {
|
||||
final android = AndroidComponent();
|
||||
android.x = 100;
|
||||
android.y = 400;
|
||||
|
||||
final android2 = AndroidComponent();
|
||||
android2.x = 100;
|
||||
android2.y = 400;
|
||||
android2.yDirection = -1;
|
||||
|
||||
final android3 = AndroidComponent();
|
||||
android3.x = 100;
|
||||
android3.y = 400;
|
||||
android3.xDirection = -1;
|
||||
|
||||
add(android);
|
||||
add(android2);
|
||||
add(android3);
|
||||
}
|
||||
|
||||
@override
|
||||
void render(Canvas canvas) {
|
||||
super.render(canvas);
|
||||
|
||||
if (debugMode()) {
|
||||
fpsTextConfig.render(canvas, fps(120).toString(), Position(0, 50));
|
||||
}
|
||||
}
|
||||
}
|
||||
21
doc/examples/debug/pubspec.yaml
Normal file
21
doc/examples/debug/pubspec.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
name: debug
|
||||
description: Flame sample for using debug features
|
||||
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.1.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flame:
|
||||
path: ../../../
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
flutter:
|
||||
assets:
|
||||
- assets/android.svg
|
||||
Reference in New Issue
Block a user