Skip to content

Commit 6fde44b

Browse files
committed
feat: Add zkapp panStart panUpdate panEnd events.
Add zkapp panStart panUpdate panEnd events.
1 parent 9eeac1d commit 6fde44b

22 files changed

+132
-49
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# 2.7.1
2+
- Add zkapp panStart panUpdate panEnd events.
3+
4+
# 2.6.1
5+
- Fix the time difference caused by switching between front and back of the app
6+
7+
# 2.5.2
8+
- Add auxiliary methods such as getTimeRatio and toSecond
9+
- Further optimize performance.
10+
11+
112
# 2.3.6
213
- Unused import: 'dart:ui'.;
314
- Using a colon as a separator before a default value is deprecated and will not be supported in language version 3.0 and later.

lib/src/animate/animator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Animator {
1414
Function? onComplete;
1515
String status = "stop";
1616

17-
ListMap _aniList = new ListMap();
17+
ListMap _aniList = ListMap();
1818
Animation? _currentAni;
1919
int _framesLength = -1;
2020

@@ -68,7 +68,7 @@ class Animator {
6868
////////////////////////////////////////////////////////////
6969
void make(String name,
7070
[List? frames, int rate = Constant.RATE, bool loop = false]) {
71-
Animation ani = new Animation(name, frames, rate, loop);
71+
Animation ani = Animation(name, frames, rate, loop);
7272
ani.framesLength = framesLength;
7373
ani.onComplete = onComplete;
7474

lib/src/app.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import './event/event.dart';
66
import './node/stage.dart';
77
import "./utils/util.dart";
88
import "./math/point.dart";
9+
import "./math/mathutil.dart";
910

1011
class ZKApp {
1112
String type = "ZKApp";
@@ -18,8 +19,11 @@ class ZKApp {
1819
double delay = 1000 / 60;
1920
int _fps = 60;
2021

22+
static bool enableFixLongInterval = false;
23+
static double longIntervalTime = 0.5;
24+
2125
ZKApp() {
22-
this.stage.context = new ZKContext();
26+
this.stage.context = ZKContext();
2327
}
2428

2529
ZKContext? get context {
@@ -72,6 +76,14 @@ class ZKApp {
7276
return this.context!.getRandomPosition();
7377
}
7478

79+
double toSecond(int milliseconds) {
80+
return MathUtil.toSecond(milliseconds);
81+
}
82+
83+
double getTimeRatio(int milliseconds) {
84+
return MathUtil.getTimeRatio(milliseconds);
85+
}
86+
7587
static void fullScreen() {
7688
return Util.fullScreen();
7789
}
@@ -112,6 +124,12 @@ class ZKApp {
112124
this.stage.tapUp(event);
113125
}
114126

127+
panStart(ZKEvent event) {}
128+
129+
panUpdate(ZKEvent event) {}
130+
131+
panEnd(ZKEvent event) {}
132+
115133
dispose() {
116134
if (debug == true) print('Zerker:: Dispose $this');
117135

lib/src/core/constant.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ class Constant {
1414
static const String ALL_FRAMES = "__ZK_ALL_FRAMES__";
1515

1616
static double ratio = 1;
17+
18+
static double afps = 0.01666;
1719
}

lib/src/math/mathutil.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import "dart:math";
22
import 'package:flutter/widgets.dart';
3+
import '../core/constant.dart';
34

45
class MathUtil {
56
static const double PI = 3.14159267;
@@ -28,6 +29,15 @@ class MathUtil {
2829
return Random().nextDouble() * (b - a) + a;
2930
}
3031

32+
static double toSecond(int milliseconds) {
33+
return milliseconds / Duration.millisecondsPerSecond;
34+
}
35+
36+
static double getTimeRatio(int milliseconds) {
37+
double second = toSecond(milliseconds);
38+
return second / Constant.afps;
39+
}
40+
3141
static Color getRandomColor() {
3242
return Color((Random().nextDouble() * 0xFFFFFF).toInt() << 0)
3343
.withOpacity(1.0);

lib/src/math/point.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Point {
1111
}
1212

1313
Point clone() {
14-
return new Point(this.x, this.y);
14+
return Point(this.x, this.y);
1515
}
1616

1717
void copy(dynamic p) {

lib/src/node/graphic.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "../utils/listmap.dart";
77

88
class ZKGraphic extends ZKNode {
99
Paint? _currentPaint;
10-
ListMap _drawList = new ListMap();
10+
ListMap _drawList = ListMap();
1111
double _alpha = 1;
1212

1313
@override
@@ -17,7 +17,7 @@ class ZKGraphic extends ZKNode {
1717
String type = "ZKGraphic";
1818

1919
ZKGraphic() : super() {
20-
//this._drawList = new ListMap();
20+
//this._drawList = ListMap();
2121
this.anchor.set(0.0, 0.0);
2222
}
2323

@@ -79,7 +79,7 @@ class ZKGraphic extends ZKNode {
7979

8080
void drawTriangle(
8181
double x1, double y1, double x2, double y2, double x3, double y3) {
82-
Path path = new Path();
82+
Path path = Path();
8383
path.moveTo(x1, y1);
8484
path.lineTo(x2, y2);
8585
path.lineTo(x3, y3);

lib/src/node/image.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ZKImage extends ZKNode {
6767
}
6868

6969
void lazyLoad(String url, [int delay = 0]) {
70-
_timer = new Timer(Duration(milliseconds: delay), () {
70+
_timer = Timer(Duration(milliseconds: delay), () {
7171
this.load(url);
7272
_timer?.cancel();
7373
});

lib/src/node/node.dart

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class ZKNode {
1313
String id = "";
1414
String type = "ZKNode";
1515

16-
Point position = new Point(0.0, 0.0);
17-
Point anchor = new Point(0.5, 0.5);
18-
Point scale = new Point(1.0, 1.0);
19-
Point skew = new Point(0.0, 0.0);
16+
Point position = Point(0.0, 0.0);
17+
Point anchor = Point(0.5, 0.5);
18+
Point scale = Point(1.0, 1.0);
19+
Point skew = Point(0.0, 0.0);
2020

2121
double oriWidth = 0;
2222
double oriHeight = 0;
@@ -28,24 +28,24 @@ class ZKNode {
2828
ZKNode? parent;
2929
Canvas? canvas;
3030
Data data = Data();
31-
Paint paint = new Paint();
31+
Paint paint = Paint();
3232

3333
ZKContext? context;
3434
dynamic expansion;
3535
double worldAlpha = 1;
3636

37-
Matrix matrix = new Matrix();
37+
Matrix matrix = Matrix();
3838
double _alpha = 1;
3939
bool _debug = false;
4040
Color? _color;
4141

4242
ZKNode() {
4343
this.id = Util.uuid();
44-
// this.position = new Point(0.0, 0.0);
45-
// this.anchor = new Point(0.5, 0.5);
46-
// this.scale = new Point(1.0, 1.0);
47-
// this.skew = new Point(0.0, 0.0);
48-
// this.matrix = new Matrix();
44+
// this.position = Point(0.0, 0.0);
45+
// this.anchor = Point(0.5, 0.5);
46+
// this.scale = Point(1.0, 1.0);
47+
// this.skew = Point(0.0, 0.0);
48+
// this.matrix = Matrix();
4949

5050
this.init();
5151
}
@@ -55,7 +55,7 @@ class ZKNode {
5555
}
5656

5757
void createPaint() {
58-
//this.paint = new Paint();
58+
//this.paint = Paint();
5959
this.paint.color = Colors.blue;
6060
this.paint.style = PaintingStyle.fill;
6161
}
@@ -141,6 +141,10 @@ class ZKNode {
141141
return Offset(regX, regY);
142142
}
143143

144+
double getTimeRatio(int milliseconds) {
145+
return MathUtil.getTimeRatio(milliseconds);
146+
}
147+
144148
////////////////////////////////////////////////////////////
145149
///
146150
/// Update, render and other related functions

lib/src/node/sprite.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ZKSprite extends ZKImage {
1212
String type = "ZKSprite";
1313

1414
/// Animator
15-
Animator animator = new Animator();
15+
Animator animator = Animator();
1616
Timer? _timer;
1717

1818
ZKSprite(
@@ -23,14 +23,14 @@ class ZKSprite extends ZKImage {
2323
double width = 100,
2424
double height = 100})
2525
: super() {
26-
//this.animator = new Animator();
26+
//this.animator = Animator();
2727
if (key != null) {
2828
this.texture = ZKAssets.getAsset(key);
2929
this.textureType = ZKAssets.getType(texture)!;
3030
if (this.texture == null)
3131
throw ("Zerker:: Sorry, this Key '$key' does not get any assets!");
3232

33-
_timer = new Timer(Duration(milliseconds: 0), () {
33+
_timer = Timer(Duration(milliseconds: 0), () {
3434
this._loadComplete(this.texture!);
3535
_timer?.cancel();
3636
});

0 commit comments

Comments
 (0)