mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
Parallax background example game
This commit is contained in:
70
doc/examples/parallax/.gitignore
vendored
Normal file
70
doc/examples/parallax/.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/parallax/.metadata
Normal file
10
doc/examples/parallax/.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: 7fc14a55af64462763d28abfb4e610086c6e0f39
|
||||
channel: dev
|
||||
|
||||
project_type: app
|
||||
5
doc/examples/parallax/README.md
Normal file
5
doc/examples/parallax/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# parallax
|
||||
|
||||
A Flame game showcasing how to use the parallax component
|
||||
|
||||
CC0 images from: https://ansimuz.itch.io/mountain-dusk-parallax-background
|
||||
BIN
doc/examples/parallax/assets/images/bg.png
Normal file
BIN
doc/examples/parallax/assets/images/bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
doc/examples/parallax/assets/images/foreground-trees.png
Normal file
BIN
doc/examples/parallax/assets/images/foreground-trees.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
6
doc/examples/parallax/assets/images/license.txt
Executable file
6
doc/examples/parallax/assets/images/license.txt
Executable file
@ -0,0 +1,6 @@
|
||||
Artwork created by Luis Zuno (@ansimuz)
|
||||
|
||||
License (CC0) You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
Get more resources at pixelgameart.org, Spread the word!
|
||||
|
||||
BIN
doc/examples/parallax/assets/images/mountain-far.png
Normal file
BIN
doc/examples/parallax/assets/images/mountain-far.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
doc/examples/parallax/assets/images/mountains.png
Normal file
BIN
doc/examples/parallax/assets/images/mountains.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
BIN
doc/examples/parallax/assets/images/trees.png
Normal file
BIN
doc/examples/parallax/assets/images/trees.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
26
doc/examples/parallax/lib/main.dart
Normal file
26
doc/examples/parallax/lib/main.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import 'package:flame/flame.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flame/components/parallax_component.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() async {
|
||||
await Flame.util.fullScreen();
|
||||
runApp(MyGame().widget);
|
||||
}
|
||||
|
||||
class MyGame extends BaseGame {
|
||||
MyGame() {
|
||||
final images = [
|
||||
ParallaxImage("bg.png"),
|
||||
ParallaxImage("mountain-far.png"),
|
||||
ParallaxImage("mountains.png"),
|
||||
ParallaxImage("trees.png"),
|
||||
ParallaxImage("foreground-trees.png"),
|
||||
];
|
||||
|
||||
final parallaxComponent = ParallaxComponent(images,
|
||||
baseSpeed: const Offset(20, 0), layerDelta: const Offset(30, 0));
|
||||
|
||||
add(parallaxComponent);
|
||||
}
|
||||
}
|
||||
25
doc/examples/parallax/pubspec.yaml
Normal file
25
doc/examples/parallax/pubspec.yaml
Normal file
@ -0,0 +1,25 @@
|
||||
name: parallax
|
||||
description: Flame sample game showcasing the parallax 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/images/bg.png
|
||||
- assets/images/mountain-far.png
|
||||
- assets/images/mountains.png
|
||||
- assets/images/trees.png
|
||||
- assets/images/foreground-trees.png
|
||||
Reference in New Issue
Block a user