If the player steps on a Button-Tile when its true, it becomes false. If the player steps on a Button-Tile when it is false, it becomes true.
The problem is, when the player stands on (intersects) the Button-Tile, it will keep updating the condition. So, from true, it becomes false. Because its false and the player intersects it, it becomes true again. True-false-true-false and so on.
I use ElapsedGameTime to make the updating process slower, and the player can have a chance to change the Button to true or false.
However, it’s not the solution I was looking for. Is there any other way to make it keep in False/True condition while the Player is standing on the Button tile?
Make the button have a
bool isPressedwhich defaults to false.Then when the player enters the tile do a check for what ever the enter event is
&& !isPressedAll you’re looking to do is combine two things in your condition, the player steps on the button and the button isn’t already triggered – you don’t have to slow down anything time wise to accomplish this. Then when the player leaves the tile or is no longer on the tile depending upon what your check is, just set the isPressed to false again.