Hello guys!
For some kind of point and click adventure game, I need to put an entity into the screen that changes its image when the mouse is over it (like a rollover) and also be able to be activated like a button to change the level...
I've been looking around in the posts for a while but i'm still not sure is the following is possible to do in Impact!, any help?
thanx so much!
1 decade ago
by Krisjet
update: function() {
x = (ig.input.mouse.x + ig.game.screen.x);
y = (ig.input.mouse.y + ig.game.screen.y);
if(x >= this.pos.x && x <= this.pos.x + this.size.x && y >= this.pos.y && y <= this.pos.y + this.size.y){
this.hover = false;
}
I use something like this, and just have a check wherever you set your animations:
if(this.hover){
this.currentAnim=this.anims.hover;
} else {
this.currentAnim = this.anims.idle;
}
1 decade ago
by Krisjet
Ok, in that first codeblock it's obviously supposed to be "this.hover = true;", I'll just post the fixed version here:
update: function() {
x = (ig.input.mouse.x + ig.game.screen.x);
y = (ig.input.mouse.y + ig.game.screen.y);
if(x >= this.pos.x && x <= this.pos.x + this.size.x && y >= this.pos.y && y <= this.pos.y + this.size.y){
this.hover = true;
} else {
this.hover = false;
}
Thank you so much Krisjet, i'll take a look at your code right now, wow, really nice!
Hi, I've been playing with the code above, and It seems to work with a fixed area in the screen, but i also need to do the same thing with entities moving around. So i wonder i there's some way to check if the mouse pointer is in collision against an entity on the screen...any clues?
tnx in advance!
Page 1 of 1
« first
« previous
next ›
last »