Hi,
I am trying to make an android game.
I have a game class that extends activity and handles all the user input. Then I have a missionView class that extends view and it draws the level on the screen.
When the user clicks on a door I want to add some animation.
What happens is: The game calls door.open. Changes the state so the view.onDraw function will draw the door half open. The game calls view.invalidate, which should redraw the screen. Then the game sleeps for half a second. Then it calls door.open again. The second time the function is called it changes the state so the view.onDraw function draws the door completely open. Then the game calls view.invalidate again.
The problem is that it does not redraw the screen when it gets to view.invalidate. If I set a break point on the line and run the debugger and click step into it does not step into my view.onDraw function. It can't even show me the code it is executing.
What I have is: Door class:
public boolean open()
{
if (doorState == DoorState.Closed)
{
doorState = DoorState.Opening;
return true;
}
else if (doorState == DoorState.Opening)
{
doorState = doorState.Open;
return true;
}
else
{
return false;
}
}
Game class:
if (tile instanceof DoorTile)
{
DoorTile doorTile = (DoorTile) tile;
Door door = doorTile.getDoor();
if (door.isClosed())
{
door.open();
selectedEntity.openDoor();
view.invalidate(); // This line does not work
try
{
Thread.sleep(500);
}
catch (InterruptedException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
door.open();
// Handled touch event so break switch statement
break;
}
}