-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapobject.ts
64 lines (52 loc) · 1.75 KB
/
mapobject.ts
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
/// <reference path="primitives.ts" />
/// <reference path="protocols.ts" />
namespace MapObjects {
export class MapObject {
getFeatures(): Feature[] {
return [];
}
hasFeature(ask:Feature): boolean {
let features = this.getFeatures();
let found=false;
features.forEach(feature => {
if(feature == ask) {
found = true;
}
});
return found;
}
/*
* the offscreen canvas is only available to objects
* which render themselves in a custom focused state.
*/
draw(context:CanvasRenderingContext2D, focused:boolean=false,offscreencanvas:CanvasRenderingContext2D=null) {
//the default implementation does nothing.
//this needs to be overriden by everyone else.
//important: the renderer already translates and
//rotates for you. as long as those flags are set.
}
hitTest(pt:Point): boolean {
return false;
}
/*
* Once an object is "focused", all mouse events will be delegated to it,
* if this function returns true.
*/
handlesMouseEvents(): boolean {
return false;
}
/*
* If this function returns true, the engine will not provide a custom
* focused style. Instead, it will call draw() with focused set to true.
*/
customFocusRenderer(): boolean {
return false;
}
mouseMove(position:Point,engine:IEngine) {
}
mouseDown(position:Point,button:number,engine:IEngine) {
}
mouseUp(position:Point,button:number,engine:IEngine) {
}
}
}