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, usedsetMouseEnabled(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?
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({
cursor:null,
init:function () {
cursor = cc.Sprite.create(imagepath);
this.addChild(cursor);
this.setMouseEnabled(true);
this.scheduleUpdate();
return true;
},
onMouseMoved:function(pEvent){
// this part of the code is here to show that this Mouse feature works properly, while the scroll wheel doesn't.
cursor.setPosition(pEvent.getLocation());
// 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)?
},
onScrollWheel:function(pEvent){
cc.log(pEvent);
// 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!