Veröffentlicht 15. September 200915 j halli,hallo Also, ich habe folgendes problem: Ich würde in Greenfoot gerne eine Linie zeichnen, bekomme das irgendwie aber nicht hin... hier mal der code: World: public class world extends World { GreenfootImage Image; public world() { super(20, 20, 10); Polygon p = new Polygon(3,3,3, 8,3,3, 5,7,3); addObject(p, 1,1); Image = new GreenfootImage(20,20); Image.setColor(Color.BLACK); Image.drawLine(1,2, 8,9); } } hier das Dreieck: import greenfoot.*; import java.awt.*; public class Polygon extends Actor { Point a; Point b; Point c; GreenfootImage Image; Polygon(int ax, int ay, int az, int bx, int by, int bz, int cx, int cy, int cz) { a = new Point(ax,ay,az); b = new Point(bx,by,bz); c = new Point(cx,cy,cz); Image = new GreenfootImage(20,20); } Polygon(Point a, Point b, Point c) { this.a = a; this.b = b; this.c = c; } public void act() { Image.setColor(Color.BLACK); Image.drawLine(a.getX(),a.getY(), b.getX(), b.getY());//das geht nicht, es kommt aber auch keine Fehlermeldung! Image.drawLine(b.getX(),b.getY(), c.getX(), c.getY()); Image.drawLine(a.getX(),a.getY(), c.getX(), c.getY()); } } und realPoint: public class realPoint { private int x; private int y; realPoint(int x, int y, int z) { calculateRealPoint(x,y,z); } public void refresh(int x, int y) { this.x = x; this.y = y; } public void calculateRealPoint(int x, int y, int z) { this.x = x*300/z; this.y = y*300/z; } } Hoffe ihr könnt mir helfen, hab auch schon probiert einfach nur eine Linie zu zeichnen... das geht irgendwie alles nicht = ( Ich bin über Hilfe sehr dankbar! mfg Benschi Fehlermeldungen kommen keine, lässt sich alles wunderbar ausführen/compilen
15. September 200915 j ok, die antwort ist denkbar einfach, es genügt natürlich nicht das Image anzulegen und dann zu bezeichnen... man muss es auch noch anzeigen lassen (setImage bzw setBackground) cu
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.