@@ -18,14 +18,9 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
1818 key = key || null ;
1919 callback = callback || null ;
2020 callbackContext = callbackContext || this ;
21- overFrame = overFrame || null ;
22- outFrame = outFrame || null ;
23- downFrame = downFrame || null ;
2421
2522 Phaser . Sprite . call ( this , game , x , y , key , outFrame ) ;
2623
27- // this.texture = PIXI.TextureCache[key];
28-
2924 this . _onOverFrameName = null ;
3025 this . _onOutFrameName = null ;
3126 this . _onDownFrameName = null ;
@@ -35,43 +30,15 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
3530 this . _onDownFrameID = null ;
3631 this . _onUpFrameID = null ;
3732
38- if ( typeof overFrame == 'string' )
39- {
40- this . _onOverFrameName = overFrame ;
41- }
42- else
43- {
44- this . _onOverFrameID = overFrame ;
45- }
46-
47- if ( typeof outFrame == 'string' )
48- {
49- this . _onOutFrameName = outFrame ;
50- this . _onUpFrameName = outFrame ;
51- }
52- else
53- {
54- this . _onOutFrameID = outFrame ;
55- this . _onUpFrameID = outFrame ;
56- }
57-
58- if ( typeof downFrame == 'string' )
59- {
60- this . _onDownFrameName = downFrame ;
61- }
62- else
63- {
64- this . _onDownFrameID = downFrame ;
65- }
66-
6733 // These are the signals the game will subscribe to
68- this . onInputOver = new Phaser . Signal ( ) ;
69- this . onInputOut = new Phaser . Signal ( ) ;
70- this . onInputDown = new Phaser . Signal ( ) ;
71- this . onInputUp = new Phaser . Signal ( ) ;
34+ this . onInputOver = new Phaser . Signal ;
35+ this . onInputOut = new Phaser . Signal ;
36+ this . onInputDown = new Phaser . Signal ;
37+ this . onInputUp = new Phaser . Signal ;
38+
39+ this . setFrames ( overFrame , outFrame , downFrame ) ;
7240
73- // Set a default signal for them
74- if ( callback )
41+ if ( callback !== null )
7542 {
7643 this . onInputUp . add ( callback , callbackContext ) ;
7744 }
@@ -91,13 +58,55 @@ Phaser.Button.prototype.constructor = Phaser.Button;
9158
9259// Add our own custom methods
9360
61+ Phaser . Button . prototype . setFrames = function ( overFrame , outFrame , downFrame ) {
62+
63+ if ( overFrame !== null )
64+ {
65+ if ( typeof overFrame === 'string' )
66+ {
67+ this . _onOverFrameName = overFrame ;
68+ }
69+ else
70+ {
71+ this . _onOverFrameID = overFrame ;
72+ }
73+ }
74+
75+ if ( outFrame !== null )
76+ {
77+ if ( typeof outFrame === 'string' )
78+ {
79+ this . _onOutFrameName = outFrame ;
80+ this . _onUpFrameName = outFrame ;
81+ }
82+ else
83+ {
84+ this . _onOutFrameID = outFrame ;
85+ this . _onUpFrameID = outFrame ;
86+ }
87+ }
88+
89+ if ( downFrame !== null )
90+ {
91+ if ( typeof downFrame === 'string' )
92+ {
93+ this . _onDownFrameName = downFrame ;
94+ }
95+ else
96+ {
97+ this . _onDownFrameID = downFrame ;
98+ }
99+ }
100+
101+ } ;
102+
94103Phaser . Button . prototype . onInputOverHandler = function ( pointer ) {
95104
96105 if ( this . _onOverFrameName != null )
97106 {
98107 this . frameName = this . _onOverFrameName ;
99108 }
100- else if ( this . _onOverFrameID != null )
109+ else if ( this . _onOverFrameID != null )
101110 {
102111 this . frame = this . _onOverFrameID ;
103112 }
0 commit comments