-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTileObject.hx
More file actions
48 lines (35 loc) · 1.18 KB
/
TileObject.hx
File metadata and controls
48 lines (35 loc) · 1.18 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
package;
import haxe.Json;
class TileObject extends NiceSprite {
private static var properties: Map<String,String>;
public function new(asset: Dynamic, index: Int, width: Int, height: Int, properties: Map<String,String>) {
super();
loadGraphic(asset, true, width, height);
var frames = [index];
if (properties.exists("frames")) {
frames = Util.arrayify(properties.get("frames")).map(function(d):Int{return d;});
}
animation.add("default", frames, Globals.AnimationFrameRate, true);
animation.play("default");
if (properties.exists("immovable")) {
immovable = Util.boolify(properties.get("immovable"));
}
if (properties.exists("health")) {
health = Util.floatify(properties.get("health"));
damageable = true;
}
groups.push(properties.get("object"));
if (properties.exists("groups"))
for (group in Util.arrayify(properties.get("groups"))) {
groups.push(group);
}
team = "map";
}
override public function hurt(damage: Float) {
if (damage >= health)
kill();
}
override public function toString() {
return "TileObject"+super.toString()+Json.stringify(properties);
}
}