1 decade ago
by phoxer
Hi, Why there is not an "onOver" state for mouse on the .bind()?? :(
I want to know if there a way to do that and show mouse pointer "like on an active button".
Thanks a lot!
1 decade ago
by phoxer
I think I found a solution, I wrote this code to do a Start Screen, but I think this is not the best way.
StartScreen = ig.Game.extend({
background: new ig.Image('media/startscreen.jpg'),
init: function() {
ig.input.bind( ig.KEY.MOUSE1, 'click' );
this.mouseOver=false;
},
update: function() {
this.parent();
//check if mouse is over a button's zone
if (ig.input.mouse.x > 300 && ig.input.mouse.x < 490 && ig.input.mouse.y > 385 && ig.input.mouse.y < 420){
if(!this.mouseOver){
this.showCursor(true);
}
if(ig.input.state('click')){
ig.system.setGame(MyGame);
this.showCursor(false);
}
}else if (ig.input.mouse.x > 600 && ig.input.mouse.x < 760 && ig.input.mouse.y > 375 && ig.input.mouse.y < 470){
if(!this.mouseOver){
this.showCursor(true);
}
if(ig.input.state('click')){
window.location ='http://www.beatsgames.com';
}
}else{
this.showCursor(false);
}
},
showCursor: function(e) {
//this function is to prevent a lot of calls to document.body ;)
if(e && !this.mouseOver){
this.mouseOver=true;
console.log("MOUSE OVER");
document.body.style.cursor = "pointer";
}else if(this.mouseOver){
this.mouseOver=false;
console.log("MOUSE OUT");
document.body.style.cursor = "default";
}
},
draw: function() {
this.parent();
this.background.draw(0,0);
}
});
what do you guys think?? there is a better way to do this?
Page 1 of 1
« first
« previous
next ›
last »