Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Greenfoot Linie zeichnen

Empfohlene Antworten

Veröffentlicht

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

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.