必经之路

抄一部心经,点一盏心灯

用户工具

站点工具


jsb:flame_parallaxcomponent

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
jsb:flame_parallaxcomponent [2024/06/25 16:21] – [3 space shootter 的设置:] lanshizijsb:flame_parallaxcomponent [2024/06/25 16:25] (当前版本) lanshizi
行 5: 行 5:
 ### 1 最简单的方法: ### 1 最简单的方法:
 可以在某个 GameWidget 中设置: 可以在某个 GameWidget 中设置:
-```+```dart
 @override @override
 Future<void> onLoad() async { Future<void> onLoad() async {
行 18: 行 18:
  
 如果用 component 自己加载,则可以用下面这个方法: 如果用 component 自己加载,则可以用下面这个方法:
-```+```dart
 class MyParallaxComponent extends ParallaxComponent<MyGame> { class MyParallaxComponent extends ParallaxComponent<MyGame> {
   @override   @override
行 37: 行 37:
 ``` ```
 ### 2 动态的背景 ### 2 动态的背景
-```+```dart
 @override @override
 Future<void> onLoad() async { Future<void> onLoad() async {
行 48: 行 48:
 ``` ```
 也可以随时 load 也可以随时 load
-```+```cpp
 @override @override
 void onLoad() { void onLoad() {
行 57: 行 57:
 ``` ```
 更高级的设置方法: 更高级的设置方法:
-```+```dart
 final images = [ final images = [
   loadParallaxImage(   loadParallaxImage(
行 93: 行 93:
 ); );
 ``` ```
 +
 ### 3 space shootter 的设置: ### 3 space shootter 的设置:
-```+```dart
 @override @override
   Future<void> onLoad() async {   Future<void> onLoad() async {
行 103: 行 104:
         ParallaxImageData('stars_2.png'),         ParallaxImageData('stars_2.png'),
       ],       ],
-      baseVelocity: Vector2(0, -5), //设置速度,向下+      baseVelocity: Vector2(0, -5), //基本的速度,向下
       repeat: ImageRepeat.repeat,       repeat: ImageRepeat.repeat,
-      velocityMultiplierDelta: Vector2(0, 5),//每一层速度不同,最外层速度最快+      velocityMultiplierDelta: Vector2(0, 5),//不同的图片,速度不一样
     );     );
     add(parallax);     add(parallax);
     }     }
 ``` ```
jsb/flame_parallaxcomponent.1719303713.txt.gz · 最后更改: 2024/06/25 16:21 由 lanshizi