San4er Posted July 9, 2014 Share Posted July 9, 2014 How can I make an action when onOver, onOut or onClick happens with my button? And how can I change it during the gameplay? Link to comment Share on other sites More sharing options...
lewster32 Posted July 10, 2014 Share Posted July 10, 2014 The Button object has multiple signals which can be added to, for example:button.onInputOver.add(function() { console.log("Pointer is over the button");}, this); Link to comment Share on other sites More sharing options...
San4er Posted July 24, 2014 Author Share Posted July 24, 2014 Oh, thanx. I have to read documentation more thoroughly Link to comment Share on other sites More sharing options...
San4er Posted July 24, 2014 Author Share Posted July 24, 2014 Here is another question.I want button.onInputUp to work only if cursor is still over the button but it works even if onInputDown was over the button and onInputUp was made out if it. Link to comment Share on other sites More sharing options...
lewster32 Posted July 24, 2014 Share Posted July 24, 2014 This is usually the desired behaviour, but you can make it work the way you're wanting like so:button.onInputUp.add(function(button, pointer, isOver) { if (isOver) { // do something here }}, this);The callback returns the button pressed, the pointer used to press it and whether the pointer was over the button when the event happened, which is handy for these situations. Link to comment Share on other sites More sharing options...
San4er Posted July 24, 2014 Author Share Posted July 24, 2014 I made exactly it like you said.Here how it works now:1. I make inputDown over the button.2. I move cursor out of the button and then make inputUp. So it seems like button hasn't been pressed.3. BUT now if I move my cursor Over the button it changes it's frame to inputDown or inputUp without making anything from *do something here*. Maybe there is already some function there and I can DELETE it, not ADD? Or it is a bug? Link to comment Share on other sites More sharing options...
lewster32 Posted July 24, 2014 Share Posted July 24, 2014 If it's the frame the button displays that you need to remain consistent with your functionality then you may have to delve into the Button object and extend it as needed, as I think the frame stuff may not be easily configurable. As I say, it's not usually desirable to have the button 'stick on' if the user moves off it and releases the mouse button/lifts their finger. Can you describe what it is you're trying to do that would need this specific behaviour? Link to comment Share on other sites More sharing options...
San4er Posted July 24, 2014 Author Share Posted July 24, 2014 Nevermind, I have found a mistake in my own code. Now it works fine Thanx anyway lewster32 1 Link to comment Share on other sites More sharing options...
Recommended Posts