Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
FogNetwork
GitHub Repository: FogNetwork/Tsunami
Path: blob/main/public/games/files/algaes-escapade/js/lib/tooltip.js
1036 views
1
2
function tooltip()
3
{
4
//Load the variables required by gamejs.sprite.Sprite
5
tooltip.superConstructor.apply(this, [0, 0]);
6
this.image = gamejs.image.load('img/blank.png');
7
this.rect = new gamejs.Rect([0, 0]);
8
9
if ( !($('#game_tooltip').length) )
10
{
11
$('#gameWindow').append('<div id="game_tooltip"></div>');
12
}
13
14
var _text = '';
15
16
this.setDimensions = function(width, height){
17
this.rect.width = width;
18
this.rect.height = height;
19
}
20
21
this.setPosition = function(x, y){
22
this.rect.x = x;
23
this.rect.y = y;
24
}
25
26
this.setText = function( text ){
27
_text = text;
28
}
29
30
this.show = function(){
31
$('#game_tooltip').html(_text);
32
$('#game_tooltip').fadeIn();
33
34
if ( null != tooltip.timer )
35
{
36
clearInterval(tooltip.timer);
37
tooltip.timer = null;
38
}
39
40
tooltip.timer = setTimeout(this.hide, 5000)
41
}
42
43
this.hide = function(animate){
44
if ( typeof(animate) == 'undefined' )
45
{
46
animate = true;
47
}
48
49
if ( animate )
50
{
51
$('#game_tooltip').fadeOut();
52
}
53
else
54
{
55
$('#game_tooltip').hide();
56
}
57
58
59
tooltip.timer = null;
60
}
61
62
this.handleCollision = function( playable, isCurrentPlayer){
63
if ( isCurrentPlayer )
64
{
65
this.show();
66
}
67
}
68
69
this.draw = function(){
70
return null;
71
}
72
}
73
74
//Set a static variable, so that we can keep track of when to hide tooltips
75
tooltip.timer = null;
76
77
//Extend the playable object so that the parent is the sprite
78
gamejs.utils.objects.extend(tooltip, gamejs.sprite.Sprite);
79