そこで、Javaでゲームを作成し、drawRect()メソッドを使用して、プレーヤー、敵、およびショットを表現することから始めました。すべてが素晴らしかった。それから私は空想を得ようと決心しました。各オブジェクトの.png画像を作成し、Graphics2D drawImage()メソッドを使用しました。すべてが減速し始めました。プロセスをスピードアップする別の方法はありますか?
私のアニメーションはスイングタイマーに基づいています
public void paint(Graphics g){
super.paint(g);
Graphics2D g2d = (Graphics2D)g;
player1.paintShips(g);
g2d.drawImage(bGround, 14, 14, this);
try{
for(Shot s: liveRounds){ //liveRounds is an ArrayList of Shots
if(!inBounds.contains(s.getRect()) || villains.collision(s)){
if(villains.collision(s)){
villains.collided(s, this);
}
liveRounds.remove(s);
roundCount--;
}
else{
s.paintShot(g, this);
}
}
}catch(ConcurrentModificationException e){};
villains.paintEnemyGrid(g, this);
g2d.setColor(Color.cyan);
g2d.draw(hitZone1);
g2d.setColor(Color.red);
g.drawString("X: " + player1.getX(1) + " Y: " + player1.getY(1), 370, 150);
g2d.draw(inBounds);
g.drawString(score + "", 440, 40);
g.dispose();
}
アニメーションに関するヒントやチュートリアルはありますか?ありがとう