URL: https://linuxfr.org/forums/programmation-java/posts/sprite-et-d%C3%A9cor--2 Title: sprite et décor Authors: nicolas Date: 2006年08月28日T14:29:15+02:00 Tags: Score: 0 Bonjour. Je programme un jeu mais je rencontre une difficulté je veux afficher un sprite sur un décor. c'est à dire une image jpg sur une autre image jpg. je n'arrive pas à enlever le carré blanc autour du sprite : il ne se fond pas dnas le décor. je crois qu'il faut uttiliser setcomposite mais je n'y arrive pas pouvez-vous m'aider ? voici mon code source de test. Attention au chemin des fichiers. pour les fichiers utiliser n'importe quelle fichier jpg import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferStrategy; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.*; public class FenetreJeuTest extends JFrame { private static final int LARGEUR_APPLICATION = 1000; private static final int HAUTEUR_APPLICATION = 550; private static final String TITRE_APPLICATION = "Super-Poulet 2006"; BufferedImage imageSuperPouletCourante; private BufferedImage decor; private BufferStrategy strategy; private Graphics2D backBuffer; public FenetreJeuTest () throws IOException{ this.setBackground(Color.WHITE); this.setTitle(TITRE_APPLICATION); this.setPreferredSize(new Dimension(LARGEUR_APPLICATION, HAUTEUR_APPLICATION)); this.addWindowListener(new WindowAdapter () { public void windowClosing(WindowEvent e) { System.exit(0); } }); this.pack(); this.setVisible(true); this.setIgnoreRepaint(true); File f = new File("D://Mes documents//développement//workspace//SuperPoulet//images//decors.jpg"); decor = ImageIO.read(f); f = new File("D://Mes documents//développement//workspace//SuperPoulet//images//Sprite//SuperPoulet//Marche//poulet marche 3_1.jpg"); imageSuperPouletCourante = ImageIO.read(f); strategy = getBufferStrategy(); backBuffer = (Graphics2D) strategy.getDrawGraphics(); renderingRoutine(); } private void renderingRoutine() { backBuffer.drawImage(decor ,0,0, this); backBuffer.drawImage( imageSuperPouletCourante, 0,0, this); strategy.show(); } public static void main(String[] args) throws IOException { // TODO Auto-generated method stub new FenetreJeuTest().show(); //setVisible(true); } }