Path: blob/main/public/games/files/algaes-escapade/js/lib/tooltip.js
1036 views
1function tooltip()2{3//Load the variables required by gamejs.sprite.Sprite4tooltip.superConstructor.apply(this, [0, 0]);5this.image = gamejs.image.load('img/blank.png');6this.rect = new gamejs.Rect([0, 0]);78if ( !($('#game_tooltip').length) )9{10$('#gameWindow').append('<div id="game_tooltip"></div>');11}1213var _text = '';1415this.setDimensions = function(width, height){16this.rect.width = width;17this.rect.height = height;18}1920this.setPosition = function(x, y){21this.rect.x = x;22this.rect.y = y;23}2425this.setText = function( text ){26_text = text;27}2829this.show = function(){30$('#game_tooltip').html(_text);31$('#game_tooltip').fadeIn();3233if ( null != tooltip.timer )34{35clearInterval(tooltip.timer);36tooltip.timer = null;37}3839tooltip.timer = setTimeout(this.hide, 5000)40}4142this.hide = function(animate){43if ( typeof(animate) == 'undefined' )44{45animate = true;46}4748if ( animate )49{50$('#game_tooltip').fadeOut();51}52else53{54$('#game_tooltip').hide();55}565758tooltip.timer = null;59}6061this.handleCollision = function( playable, isCurrentPlayer){62if ( isCurrentPlayer )63{64this.show();65}66}6768this.draw = function(){69return null;70}71}7273//Set a static variable, so that we can keep track of when to hide tooltips74tooltip.timer = null;7576//Extend the playable object so that the parent is the sprite77gamejs.utils.objects.extend(tooltip, gamejs.sprite.Sprite);7879