diff --git a/doc/examples/parallax/.gitignore b/doc/examples/parallax/.gitignore new file mode 100644 index 000000000..07488ba61 --- /dev/null +++ b/doc/examples/parallax/.gitignore @@ -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 diff --git a/doc/examples/parallax/.metadata b/doc/examples/parallax/.metadata new file mode 100644 index 000000000..6a633e088 --- /dev/null +++ b/doc/examples/parallax/.metadata @@ -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 diff --git a/doc/examples/parallax/README.md b/doc/examples/parallax/README.md new file mode 100644 index 000000000..e5f5653be --- /dev/null +++ b/doc/examples/parallax/README.md @@ -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 diff --git a/doc/examples/parallax/assets/images/bg.png b/doc/examples/parallax/assets/images/bg.png new file mode 100644 index 000000000..a4a480568 Binary files /dev/null and b/doc/examples/parallax/assets/images/bg.png differ diff --git a/doc/examples/parallax/assets/images/foreground-trees.png b/doc/examples/parallax/assets/images/foreground-trees.png new file mode 100644 index 000000000..66bbcaec6 Binary files /dev/null and b/doc/examples/parallax/assets/images/foreground-trees.png differ diff --git a/doc/examples/parallax/assets/images/license.txt b/doc/examples/parallax/assets/images/license.txt new file mode 100755 index 000000000..2661e4286 --- /dev/null +++ b/doc/examples/parallax/assets/images/license.txt @@ -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! + diff --git a/doc/examples/parallax/assets/images/mountain-far.png b/doc/examples/parallax/assets/images/mountain-far.png new file mode 100644 index 000000000..745ef833f Binary files /dev/null and b/doc/examples/parallax/assets/images/mountain-far.png differ diff --git a/doc/examples/parallax/assets/images/mountains.png b/doc/examples/parallax/assets/images/mountains.png new file mode 100644 index 000000000..90ec81645 Binary files /dev/null and b/doc/examples/parallax/assets/images/mountains.png differ diff --git a/doc/examples/parallax/assets/images/trees.png b/doc/examples/parallax/assets/images/trees.png new file mode 100644 index 000000000..936c5f7a1 Binary files /dev/null and b/doc/examples/parallax/assets/images/trees.png differ diff --git a/doc/examples/parallax/lib/main.dart b/doc/examples/parallax/lib/main.dart new file mode 100644 index 000000000..d4e1d1e97 --- /dev/null +++ b/doc/examples/parallax/lib/main.dart @@ -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); + } +} diff --git a/doc/examples/parallax/pubspec.yaml b/doc/examples/parallax/pubspec.yaml new file mode 100644 index 000000000..97338cc98 --- /dev/null +++ b/doc/examples/parallax/pubspec.yaml @@ -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