1 decade ago by CaueCR
Hello again!
I am working in a project where an entity animation must change when I click it. The problem is, when I write the condition for colision, even what was working before stops working
The following is the code for colision with mouse coordinates I've made:
If I change the code of the second condition to be like the first condition, none of them works.
I've been putting this code in the update method of my entities, can anyone help me?
Thanks for your time!
CauĂȘ.
I am working in a project where an entity animation must change when I click it. The problem is, when I write the condition for colision, even what was working before stops working
The following is the code for colision with mouse coordinates I've made:
if(ig.input.state('click') && (ig.input.mouse.x >= this.pos.x && ig.input.mouse.x <= this.pos.x + this.size.x) && (ig.input.mouse.y >= this.pos.y && ig.input.mouse.y <= this.pos.y + this.size.y)){ this.currentAnim = this.anims.erro; if(this.flag == false){ this.flag = true; } } if(ig.input.state('click') && this.flag == true){ this.currentAnim = this.anims.idle; if((ig.input.mouse.x >= this.pos.x && ig.input.mouse.x <= this.pos.x + this.size.x) && (ig.input.mouse.y >= this.pos.y && ig.input.mouse.y <= this.pos.y + this.size.y)){ this.flag = false; } } this.parent();
If I change the code of the second condition to be like the first condition, none of them works.
I've been putting this code in the update method of my entities, can anyone help me?
Thanks for your time!
CauĂȘ.