Pongゲームの作成方法を示すガイドに従っています。スレッドを作成し、ボールを動かす関数を呼び出す部分があります。
これは私が作成したコードです:
package com.ozadari.pingpong;
public class PingPongGame extends Thread {
private Ball gameBall;
private PingPongView gameView;
public PingPongGame(Ball theBall,PingPongView mainView)
{
this.gameBall = theBall;
this.gameView = mainView;
}
@Override
public void run()
{
while(true)
{
this.gameBall.moveBall();
this.gameView.postInvalidate();
try
{
PingPongGame.sleep(5);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}}
スレッドは呼び出されて機能していますが、何も出力されません。無限ループをキャンセルして、ループを100回実行しようとしました。しばらく待つと、100回実行した後のように画面に印刷されますが、途中で何も印刷されません。
何が問題ですか?どうすれば修正できますか?