Re: Serious problem with java font animation
From: Tristan (shiranaihito_at_hotmail.com)
Date: 11/25/03
- Next message: Oz Levanon: "File Descriptors Leak"
- Previous message: Christophe Vanfleteren: "Re: jsp and Expression langage question ?"
- In reply to: Knute Johnson: "Re: Serious problem with java font animation"
- Next in thread: Alex Hunsley: "Re: Serious problem with java font animation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Nov 2003 01:59:56 -0800
Hi,
> Well use a smaller increase amount and don't Font.deriveFont() in the
> loop. Create an array of fonts with Font.deriveFont() in the
> constructor. You might provide your code so we can see exactly what
> your are doing.
the animation loop is like this:
public void run() {
while(true) {
text.update();
repaint();
try {
Thread.sleep(20); //Frames per second
} catch (...)
}
}
Paint method:
public void paint(Graphics g) {
super.paint(g);
text.paint(g);
}
Text is an object that has an update method:
...
private int counter;
private Font textFont;
private int textSize;
private int stop = DISPLAY_TIME/REFRESH_RATE;
public void update() {
counter++;
if (counter <= stop) {
textize += ADDITIONAL_POINTS/stop; //ADDITIONAL_POINTS is 50
pt
textFont = textFont.deriveFont(((float) textSize));
}
}
public void paint(g) {
g.setFont(textFont);
g.drawString("Slow and bad animation !");
}
The string should be current string size + 50 pt in the end, so I
divided the steps from 50 pt. The result is the points to increase the
string size for each loop until the given display time.
Bye, Tristan.
- Next message: Oz Levanon: "File Descriptors Leak"
- Previous message: Christophe Vanfleteren: "Re: jsp and Expression langage question ?"
- In reply to: Knute Johnson: "Re: Serious problem with java font animation"
- Next in thread: Alex Hunsley: "Re: Serious problem with java font animation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|