ERLEDIGT
NEIN
NEIN
ANTWORTEN
2
2
ZUGRIFFE
464
464
EMPFEHLEN
-
Hi,
ist es möglich ein Image oder eine Zeichnung ohne Repaint eine andere Positon zuzuordnen? Ich würde gerne sowas wie ein Ball hüpfen lassen. Das blöde dabei ist nur das er zu flackern anfängt.
-
15.11.04 12:41 #2
Dafür gibt's elegante Lösungen im Java-Buch:
http://download.javabuch.de/hjp3html.zip
Kapitel: 34.2.3 Animation mit Grafikprimitiven
CU schnuffie
-
15.11.04 17:27 #3
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo!
Schau mal hier:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
package de.tutorials; import java.awt.Graphics2D; import java.awt.image.BufferStrategy; import javax.swing.JFrame; public class FlyBall extends JFrame { private BufferStrategy strategy; private Thread animator = new Thread(){ int x, y; public void run(){ while(true){ Graphics2D g = (Graphics2D)strategy.getDrawGraphics(); g.clearRect(0,0,320,240); g.fillOval((x+=4) % 320,(y+=3) % 240,25,25); g.dispose(); strategy.show(); try { Thread.sleep(20L); } catch (InterruptedException e) { e.printStackTrace(); } } } }; public FlyBall(){ super("BallJumb"); setDefaultCloseOperation(EXIT_ON_CLOSE); setIgnoreRepaint(true); setSize(320,240); setVisible(true); createBufferStrategy(2); strategy = getBufferStrategy(); } public static void main(String[] args) { new FlyBall().start(); } private void start() { animator.start(); } }
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
Ähnliche Themen
-
"XPresso" - Partikel in bestimmte Richtung bewegen
Von duffypuffy im Forum Cinema 4DAntworten: 3Letzter Beitrag: 10.07.07, 12:49 -
Bilder in einem Video "bewegen"
Von Hanselmann im Forum Videoschnitt, Videotechnik & -produktionAntworten: 4Letzter Beitrag: 08.09.05, 15:15 -
In PHP-eMails: Zahl anstatt von "7.5" mit "7,50" anzeigen
Von altox-de im Forum PHPAntworten: 4Letzter Beitrag: 30.12.04, 19:41 -
"Like" in PHP anstatt von == um Vergleich zu machen?
Von petschni im Forum PHPAntworten: 8Letzter Beitrag: 20.10.04, 12:52 -
"MS-DOS-Version" anstatt "Nur Eingabeaufforderung"?
Von daDom im Forum Virtualisierung (VMWare, Virtual PC & Co.)Antworten: 11Letzter Beitrag: 21.11.03, 12:36





Zitieren

Login





