public void paint(Graphics g){
super.paint(g);
g.setColor(Color.BLACK);
g.fillRect(0, 0, 300, 400);
for(int x = 0; x < 10; x++){
for(int y = 0; y < 10; y++){
rect = new Rectangle(getSourceRectangle(getTileIndex(x,y)));
try{
Tile = createImage(new FilteredImageSource(TileMap.getSource(), new CropImageFilter(rect.x,rect.y,rect.width,rect.height)));
}catch(Exception e){}
g.drawImage(Tile,x*TileSize,y*TileSize,this);
}
}
Toolkit.getDefaultToolkit().sync();
g.dispose();
}
3 replies to this topic
#1
Posted 16 August 2011 - 05:59 PM
This is probably a very simple problem but i was messing with some tile sheets and for some reason it isnt drawing any of the tiles out. any idea?
|
|
|
#2
Posted 21 August 2011 - 08:15 AM
Are you drawing onto a JPanel? an Applet? A Window?
#3
Posted 21 August 2011 - 09:37 AM
a JPanel. this is in a class with an extension of JPanel thats added to another JFrame class
#4
Posted 22 August 2011 - 04:10 PM
I recommend adding your painting code inside of the paintComponent(Graphics g) method instead of paint(Graphics g).
Are you manually doing the repainting?
Are you manually doing the repainting?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









