1 decade ago by SnakePlissken
Ok my game has been progressing pretty smoothly lately but running into a problem with the input state of the mouse click sticking. Essentially I am capturing the mouse click to see if its pressed and then seeing if the pos.x and pos.y are in the grid that holds my entity.
This will work for the first time it fires however when trying to use this on a separate entity all I need to do is click anywhere and the mouse over to its location and it will fire the if statement.
So what would cause the .pressed state to hold up?
Here is the code that fires on click and in current entity grid.
This will work for the first time it fires however when trying to use this on a separate entity all I need to do is click anywhere and the mouse over to its location and it will fire the if statement.
So what would cause the .pressed state to hold up?
Here is the code that fires on click and in current entity grid.
var currentXFloor; var currentYFloor; var CurrentXCeiling; var currentYCeiling; currentXFloor = this.pos.x; currentYFloor = this.pos.y; currentXCeiling = currentXFloor + 32; currentYCeiling = currentYFloor + 32; if((ig.input.pressed('click')) && (ig.input.mouse.y <= currentYCeiling && ig.input.mouse.y >= currentYFloor ) && (ig.input.mouse.x <= currentXCeiling && ig.input.mouse.x >= currentXFloor) ) { // MY CODE }