Skip to content

Commit fe5b682

Browse files
Michael DobekidisMichael Dobekidis
Michael Dobekidis
authored and
Michael Dobekidis
committed
Resolves #6
1 parent f349f5d commit fe5b682

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

Phasetips.js

+12
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ var Phasetips = function (localGame, options) {
4343
_this.mainGroup.visible = true;
4444
_this.mainGroup.alpha = 1;
4545
}
46+
47+
if(_options.onHoverCallback){
48+
_options.onHoverCallback();
49+
}
4650
};
4751

4852
this.onHoverOut = function () {
@@ -58,6 +62,10 @@ var Phasetips = function (localGame, options) {
5862
else {
5963
_this.mainGroup.alpha = 0;
6064
}
65+
66+
if(_options.onOutCallback){
67+
_options.onOutCallback();
68+
}
6169
};
6270

6371
this.createTooltips = function () {
@@ -92,11 +100,15 @@ var Phasetips = function (localGame, options) {
92100
var _object = _options.targetObject || game; // any object
93101
var _animationSpeedShow = _options.animationSpeedShow || 300;
94102
var _animationSpeedHide = _options.animationSpeedHide || 200;
103+
var _onHoverCallback = _options.onHoverCallback || function() {};
104+
var _onOutCallback = _options.onOutCallback || function() {};
95105

96106
_options.animation = _animation;
97107
_options.animationDelay = _animationDelay;
98108
_options.animationSpeedShow = _animationSpeedShow;
99109
_options.animationSpeedHide = _animationSpeedHide;
110+
_options.onHoverCallback = _onHoverCallback;
111+
_options.onOutCallback = _onOutCallback;
100112

101113
////////////////////////////////////////////////////////////////////////////////////
102114
var tooltipBG;

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ The game instance that we want the tooltips to appear to, such as "game"
5454
wordWrap: true,
5555
wordWrapWidth: 200
5656
}</li>
57+
<li><strong>onHoverCallback: </strong> Calls a function when hover occurs (default: fn)</li>
58+
<li><strong>onOutCallback: </strong> Calls a function when hover ends (default: fn)</li>
5759

5860
</ul>
5961

assets/char1-stroke.png

60.9 KB
Loading

core.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var slider;
77
GameState.prototype.preload = function () {
88
this.load.image('bg', "http://i221.photobucket.com/albums/dd22/djmid71/bg1_zpsxrhh1f86.jpg");
99
this.load.image("char", "assets/char1.png");
10+
this.load.image("char-stroke", "assets/char1-stroke.png");
1011
this.load.image("char2", "assets/char2.png");
1112
this.load.image("customTip", "assets/customTip.png");
1213

@@ -65,7 +66,13 @@ GameState.prototype.create = function () {
6566
targetObject: block1,
6667
context: "A cute bunny but with a lot of text, that needs to wrap!",
6768
strokeColor: 0xff0000,
68-
position: "right"
69+
position: "right",
70+
onHoverCallback: function() {
71+
block1.loadTexture("char-stroke");
72+
},
73+
onOutCallback: function() {
74+
block1.loadTexture("char");
75+
}
6976
});
7077

7178
var tip2 = new Phasetips(_game, {

0 commit comments

Comments
 (0)