Mouse Scroll Wheel support?

Mouse Scroll Wheel support?
0.0 0


Hey, I’m making a little puzzle game that I planned to use the scroll wheel on the mouse for some mechanics.
Specifically, I want to do something with scrolling up and down. The problem is that I don’t know how to trigger that.

By looking at Cocos’ source code, I can see that ccLayer has this function: onScrollWheel_ but that function never triggers!
I created a layer, used
setMouseEnabled(true), and implemented a littlecc.log()_ when it triggers. I tried, scrolling up, down and clicking the button, but nothing happens.

Does CocosHTML5 actually has this implemented? Or is there some step that I may be missing?




scrollwheel api is there, but we are still “experimenting”

you can enable a layer’s mouse events with “setMouseEnabled(true)” instead of setTouchEnabled

however this set of event does not work on touch devices

Can you post your code so I can see what is missing from your code?


Hao Wu wrote:

Can you post your code so I can see what is missing from your code?

Sure thing man, here’s a narrowed down view on how my code is structured:

var QTBO1 = cc.Layer.extend({

    init:function () {
        cursor = cc.Sprite.create(imagepath);
        return true;

        // this part of the code is here to show that this Mouse feature works properly, while the scroll wheel doesn't.
        // in this case, we get infromation from pEvent (location), but what information can we get from the scroll wheel (parameter or something from the mouse dispatcher maybe)?

        // It's supposed to show the pEvent (through the console log) that is triggered from using the wheel, but it doesn't!
        // I tried clicking the wheel and scrolling up and down, but nothing happens :(

That’s it mostly. If you say the Mouse features are still being experimented upon, I understand. I’m in the process of changing my controls to keyboard ones (my game is aimed to be played at a computer), so there is no rush to use the mouse.
Thanks for the reply Hao! :slight_smile:


Hi, does anyone know what’s the status on this?

edit: I’ve just checked the tests and this works fine now.

Search for “onScrollWheel” on “samples/tests/tests-main.js” to see an example of usage.