-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoreview.js
44 lines (40 loc) · 1.26 KB
/
scoreview.js
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
/// <summary> Display the player score. </summary>
/// <remarks>
/// <para>
/// </para>
/// </remarks>
var ScoreView = function(paper, anchorPoint, textColor, textSize,
layout, name, initialScore){
// Collect parameters.
this.paper = paper;
this.anchorPoint = anchorPoint;
this.textColor = textColor;
this.textSize = textSize;
this.layout = layout;
this.name = name;
this.score = initialScore;
var textAnchor = "";
if(this.layout === "left"){
textAnchor = "start";
}
else if(this.layout === "right"){
textAnchor = "end";
}
// Setup text object.
var attrs = {"font-size" : this.textSize + "px",
"font-family" : "Courier",
"text-anchor" : textAnchor,
"stroke" : this.textColor};
this.textElement = paper.text(anchorPoint.x, anchorPoint.y,
this.name + "\n" + this.score).attr(attrs);
/// <summary> Update the score. </summary>
this.updateScore = function(score){
this.score = score;
this.textElement.attr("text", this.name + "\n" + this.score);
}
}
/// <summary> Remove all canvas elements from the canvas. </summary>
ScoreView.prototype.destroyCanvasElements = function(){
this.textElement.remove();
}
bindAllFunctions(ScoreView);