Witam.
Chciałbym aby po przejsciu animacji słoneczka zmieniającego kolor po kliknięciu myszki uruchamiała się animacja spadającego meteoru. Niestety po uzyciu funkcji mouseClick nic się dzieje.
import java.applet.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
public class naplet extends Applet
{
//deklaracja wstawiania obrazkow
Image obraz;
Image obraz2;
public boolean mouseClick = false;
public void init()
{
obraz=getImage(getDocumentBase(),"drzefo.jpg");
obraz2=getImage(getDocumentBase(),"drzefo2.jpg");
}
int tabX[]={50,70,55,70,30,45,30};
int tabY[]={220,240,240,260,260,240,240};
public void mousePressed(MouseEvent event)
{
mouseClick = true;
event.consume();
}
public void paint (Graphics gDC)
{
int i,j;
gDC.setColor(new Color(96,2,1));
//blok
gDC.fillRect(300,170,70,100);
//okno nr1
gDC.setColor(new Color(255,204,153));
gDC.fillRect(310,180,20,20);
//okno nr2
gDC.setColor(new Color(255,204,153));
gDC.fillRect(340,180,20,20);
//okno nr3
gDC.setColor(new Color(255,204,153));
gDC.fillRect(310,220,20,20);
//okno nr4
gDC.setColor(new Color(255,204,153));
gDC.fillRect(340,220,20,20);
gDC.setColor(new Color(96,2,1));
//blok2
gDC.fillRect(200,170,70,100);
//okno nr1
gDC.setColor(new Color(255,204,153));
gDC.fillRect(210,180,20,20);
//okno nr2
gDC.setColor(new Color(255,204,153));
gDC.fillRect(240,180,20,20);
//okno nr3
gDC.setColor(new Color(255,204,153));
gDC.fillRect(210,220,20,20);
//okno nr4
gDC.setColor(new Color(255,204,153));
gDC.fillRect(240,220,20,20);
//choinka
gDC.setColor(new Color(0,255,0));
gDC.drawPolygon(tabX,tabY,7);
gDC.fillPolygon(tabX,tabY,7);
//pniaczek
gDC.setColor(new Color(150,75,0));
gDC.fillRect(40,260,20,10);
//droga
gDC.setColor(new Color(54,65,53));
gDC.fillRect(1,270,370,30);
//drzefa 1 i 2
gDC.drawImage(obraz,80,220,this);
gDC.drawImage(obraz2,105,235,this);
int g;
g=0;
int h = 20;
//slońce
for(j=0;j<300;j++)
{
if (j < 20)
{
j++;
}
if(j >= 20 && j < 50)
{
if(j % 10 == 0)
h++;
j++;
}
if(j >= 50 && j < 80)
{
if(j % 9 == 0)
h++;
j++;
}
if(j >= 80 && j < 110)
{
if(j % 8 == 0)
h++;
j++;
}
if(j >= 110 && j < 140)
{
if(j % 7 == 0)
h++;
j++;
}
if(j >= 140 && j < 170)
{
if(j % 6 == 0)
h++;
j++;
}
if(j >= 170 && j < 200)
{
if(j % 5 == 0)
h++;
j++;
}
if(j >= 200 && j < 230)
{
if(j % 4 == 0)
h++;
j++;
}
if(j >= 230 && j < 260)
{
if(j % 3 == 0)
h++;
j++;
}
if(j >= 260 && j < 300)
{
if(j % 2 == 0)
h++;
j++;
}
g++;
gDC.setColor(new Color(255,255-g,0));
gDC.fillOval(50+j,h,50,50);
try
{
Thread.sleep(30);
}
catch(InterruptedException e) {}
gDC.setColor(new Color(255,255,255));
gDC.fillOval(50+j,h,50,50);
}
//METEŁORZE
//if(mouseClick == true)
//{
for(i=0;i<210;i++)
{
gDC.setColor(new Color(230,28,102));
gDC.fillOval(160,50+i,30,30);
try
{
Thread.sleep(5);
}
catch(InterruptedException ie) {
ie.printStackTrace();
}
gDC.setColor(new Color(255,255,255));
gDC.fillOval(160,50+i,30,30);
}
//}
//LEJ PO METEREŁORZE
gDC.setColor(new Color(255,255,255));
gDC.fillOval(160,260,30,30);
}
}