Bonjour,

Sur Java swing, jeu veux afficher plusieurs images sasn écrasement l'une sur l'autre :

example code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
public void paint(Graphics g) {
 
 
	    super.paint(g);
	    ImageIcon vide = new ImageIcon("C:\\ressources\\UMP0%.png");
	    vide.paintIcon(this, g, 70,70); 
	  // position.translate(vitesse.x, vitesse.y);
	 //  g.fillRect(70, 70, 64, 64);
 
 
 
	    super.paint(g);
	    ImageIcon metal = new ImageIcon("C:\\ressources\\metal.png");
	    metal.paintIcon(this, g, 120,170); 
 
		// On ajoute  la position le delta x et y de la vitesse
		position.translate(vitesse.x, vitesse.y);
		position2.translate(vitesse.x, vitesse.y);
		position3.translate(vitesse.x, vitesse.y);
	    g.fillRect(position.x, position.y, taille, taille);
	//	g.setColor(Color.BLUE);
 
	}
résutat en générale a la fin pour plusieurs images est comme suit :

Nom : image example.jpg
Affichages : 195
Taille : 33,1 Ko