-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneElement.pde
More file actions
66 lines (53 loc) · 1.43 KB
/
SceneElement.pde
File metadata and controls
66 lines (53 loc) · 1.43 KB
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
abstract class SceneElement implements GameElement {
// ----- Fields
private TweenManager tweenManager;
public Vec2Int position;
public float rotation;
public float scale;
// ----- Constructors
public SceneElement() {
position = Vec2Int.ZERO;
scale = 1f;
}
// ----- Methods
public void setTweenManager(TweenManager value) {
tweenManager = value;
}
public Collider getCollider() {
return null;
}
}
class SceneElementTweenAccessor implements TweenAccessor<SceneElement> {
// ----- Fields
public static final int POS_X_ID = 1, POS_Y_ID = 2, SCALE_ID = 3;
// ----- Methods
@Override
public int getValues(SceneElement target, int tweenTypeID, float[] returnValues) {
switch (tweenTypeID) {
case POS_X_ID:
returnValues[0] = target.position.x;
break;
case POS_Y_ID:
returnValues[0] = target.position.y;
break;
case SCALE_ID:
returnValues[0] = target.scale;
break;
};
return 1;
}
@Override
public void setValues(SceneElement target, int tweenTypeID, float[] newValues) {
switch (tweenTypeID) {
case POS_X_ID:
target.position = new Vec2Int(newValues[0], target.position.y);
break;
case POS_Y_ID:
target.position = new Vec2Int(target.position.x, newValues[0]);
break;
case SCALE_ID:
target.scale = newValues[0];
break;
};
}
}