-
Notifications
You must be signed in to change notification settings - Fork 469
/
main.dart
119 lines (109 loc) · 3.79 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import 'package:flare_flutter/flare_controller.dart';
import 'package:flare_flutter/flare.dart';
import 'package:flare_flutter/flare_actor.dart';
import 'package:flare_dart/math/mat2d.dart';
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Rockin\' Penguin',
theme: new ThemeData(primarySwatch: Colors.blue),
home: new MyHomePage(title: 'Rockin\' Penguin'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> implements FlareController {
double _rockAmount = 0.5;
double _speed = 1.0;
double _rockTime = 0.0;
bool _isPaused = false;
ActorAnimation _rock;
@override
void initialize(FlutterActorArtboard artboard) {
_rock = artboard.getAnimation("music_walk");
}
@override
void setViewTransform(Mat2D viewTransform) {}
@override
bool advance(FlutterActorArtboard artboard, double elapsed) {
_rockTime += elapsed * _speed;
_rock.apply(_rockTime % _rock.duration, artboard, _rockAmount);
return true;
}
@override
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.grey,
appBar: new AppBar(title: new Text(widget.title)),
body: new Stack(
children: [
Positioned.fill(
child: FlareActor("assets/Penguin.flr",
alignment: Alignment.center,
isPaused: _isPaused,
fit: BoxFit.cover,
animation: "walk",
controller: this)),
Positioned.fill(
child: new Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
height: 200,
color: Colors.black.withOpacity(0.5),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text("Mix Amount",
style: TextStyle(color: Colors.white)),
new Slider(
value: _rockAmount,
min: 0.0,
max: 1.0,
divisions: null,
onChanged: (double value) {
setState(() {
_rockAmount = value;
});
},
),
new Text("Speed",
style: TextStyle(color: Colors.white)),
new Slider(
value: _speed,
min: 0.2,
max: 3.0,
divisions: null,
onChanged: (double value) {
setState(() {
_speed = value;
});
},
),
new Text("Paused",
style: TextStyle(color: Colors.white)),
new Checkbox(
value: _isPaused,
onChanged: (bool value) {
setState(() {
_isPaused = value;
});
},
)
],
)),
]))
],
),
);
}
}