wgge 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import AnimationController from "./AnimationController";
|
|
2
|
+
import {EASING_FLAT} from "../animation/ProgressValue";
|
|
3
|
+
import AnimatedRotation from "../animation/AnimatedRotation";
|
|
4
|
+
|
|
5
|
+
export default class AnimationRotationVector2Controller extends AnimationController {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type Vector2
|
|
9
|
+
*/
|
|
10
|
+
model;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @type AnimatedRotation
|
|
14
|
+
*/
|
|
15
|
+
animatedX;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type AnimatedRotation
|
|
19
|
+
*/
|
|
20
|
+
animatedY;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param game GameModel
|
|
25
|
+
* @param model Vector2
|
|
26
|
+
* @param target Vector2
|
|
27
|
+
* @param duration Number
|
|
28
|
+
* @param easing (float) => float
|
|
29
|
+
* @param elapsed Number
|
|
30
|
+
*/
|
|
31
|
+
constructor(game, model, target, duration, easing = EASING_FLAT, elapsed = 0) {
|
|
32
|
+
super(game, model);
|
|
33
|
+
this.model = model;
|
|
34
|
+
this.animatedX = new AnimatedRotation(model.x, target.x, duration, easing, elapsed);
|
|
35
|
+
this.animatedY = new AnimatedRotation(model.y, target.y, duration, easing, elapsed);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
updateInternal(delta) {
|
|
39
|
+
this.model.set(this.animatedX.get(delta), this.animatedY.get(delta));
|
|
40
|
+
if (this.animatedX.isFinished() && this.animatedY.isFinished()) {
|
|
41
|
+
this.finished();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ObjectModel from "../ObjectModel";
|
|
2
2
|
import Rotation from "./Rotation";
|
|
3
|
+
import NumberHelper from "../../helper/NumberHelper";
|
|
3
4
|
|
|
4
5
|
export default class Vector2 extends ObjectModel {
|
|
5
6
|
x;
|
|
@@ -171,7 +172,7 @@ export default class Vector2 extends ObjectModel {
|
|
|
171
172
|
this.removeEventListener('change', eventHandler);
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
toString() {
|
|
175
|
-
return `[${this.x},${this.y}]`;
|
|
175
|
+
toString(decimals = 2) {
|
|
176
|
+
return `[${NumberHelper.round(this.x, decimals)},${NumberHelper.round(this.y, decimals)}]`;
|
|
176
177
|
}
|
|
177
178
|
}
|
|
@@ -31,6 +31,6 @@ export default class DirtyValueRenderer extends DomRenderer {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
updateValue() {
|
|
34
|
-
this.container.innerText = this.formatter ? this.formatter(this.model.get()) : this.model.get();
|
|
34
|
+
this.container.innerText = this.formatter ? this.formatter(this.model.get()) : String(this.model.get());
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import DomRenderer from "./DomRenderer";
|
|
2
2
|
import DOMHelper from "../../helper/DOMHelper";
|
|
3
|
-
import NumberHelper from "../../helper/NumberHelper";
|
|
4
3
|
|
|
5
4
|
export default class Vector2Renderer extends DomRenderer {
|
|
6
5
|
|
|
@@ -32,6 +31,6 @@ export default class Vector2Renderer extends DomRenderer {
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
updateValue() {
|
|
35
|
-
this.container.innerText = this.formatter ? this.formatter(this.model) :
|
|
34
|
+
this.container.innerText = this.formatter ? this.formatter(this.model) : this.model.toString();
|
|
36
35
|
}
|
|
37
36
|
}
|