My main loop:
...
// Variables declaration
TouchCollection touch_;
...
private void InitializeAll()
{
...
player = new Player(touch_);
...
}
protected override void Update(GameTime gametime)
{
touch_ = TouchPanel.GetState();
player_.Update(gametime);
...
}
I want to call TouchPanel.GetState();
just one time for every update, so I didn't put it also in player's update loop and in every other object's update loop that needs to know touch state. So I passed touch_
into player's constructor, but I doesn't work: player doesn't see any update of touch_
variable.
I understand that this is a problem related to the fact that touch_
is being assigned everytime.
How can I solve this?