0

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?

Martijn Pieters
  • 14,499
  • 10
  • 57
  • 58
aldok
  • 111
  • 2

2 Answers2

4

The condition is wrong: do not update the state when the player stands on the tile, update the state when the player enters the tile. This way they can stand on a tile as long as they want with no change.

Chris Pitman
  • 3,426
  • 1
  • 18
  • 21
0

When the player enters the tile, set an Entered flag for that tile to true. As long as this flag is true, don't update the Button-tile status.

When the player exits the tile, set the Entered flag to false.

Martijn Pieters
  • 14,499
  • 10
  • 57
  • 58
agent13
  • 391
  • 1
  • 2
  • 8