mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-04 13:08:09 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			680 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			680 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
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);
 | 
						|
  }
 | 
						|
}
 |