loover Posted September 19, 2017 Share Posted September 19, 2017 How to add mouse wheel callback only for specific sprite/group? game.input.mouse.mouseWheelCallback adds a callback for a whole game. And if a game have more than one scrollers they move synchronously. Link to comment Share on other sites More sharing options...
samme Posted September 19, 2017 Share Posted September 19, 2017 There's only one mouse wheel. What do you want to do with the specific sprite/group? Link to comment Share on other sites More sharing options...
loover Posted September 20, 2017 Author Share Posted September 20, 2017 Scrolling it. I have a two "screens" (group with sprites). Like a list with many items. Some items are hidden and scrolling using for reveal they. Need to achieve the scrolling if user use scroll wheel in any place on the screen. But if first screen is hidden (alpha = 0, x = -10000, for example) and user try to scrolling the another one - list on the first screen scrollied also. Link to comment Share on other sites More sharing options...
samid737 Posted September 20, 2017 Share Posted September 20, 2017 You can add the screens/list to some array, then iterate trough that array to check if some condition is met when the mouseWheelCallback is executed: The example can also check if mouse is hovering over some list, see commented code inside scroll(). Link to comment Share on other sites More sharing options...
loover Posted September 21, 2017 Author Share Posted September 21, 2017 So impossible to have the different mouse wheel callbacks for different sprites/groups? Is possible to add the mouse wheel functionality to different list classes? E .g. to have an own callback for different instances of this class. Link to comment Share on other sites More sharing options...
samme Posted September 21, 2017 Share Posted September 21, 2017 Can you just add one callback and then treat the different sprites/groups differently? Link to comment Share on other sites More sharing options...
loover Posted September 21, 2017 Author Share Posted September 21, 2017 Yes, I did it. Although this is not very convenient because the lists in the different classes. Link to comment Share on other sites More sharing options...
Konstantine Posted May 4, 2019 Share Posted May 4, 2019 Hi Loover, can you explain how you did it? I have used mousewheelcallback on input over of each sprites. But it is still working on input out. I have added function in input out to remove input over events. Still its catching mousewheelcallback. Link to comment Share on other sites More sharing options...
Recommended Posts