Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
331 views
in Technique[技术] by (71.8m points)

java - Method from another class JAVA_with GLOOP 3d lib

Sorry for disturbing you at this time but for some reason when i want to call a method from another class (im using BlueJ btw.) it says Non-static method Licht_an (or light on in English) cannot be referenced from a static context. My friends at school did the exact same thing at it worked for them just not for me. first code is part of the main class the second is part of the second class

    public void tastaturSteuerung(){
    while(!tastatur.istGedrueckt(' ')){
       if(tastatur.rechts()){
        kamera.verschiebe(1,0,0);
        }
       if(tastatur.links()){
        kamera.verschiebe(-1,0,0);
        }
       if(tastatur.unten()){
        kamera.verschiebe(0,0,1);
        }
       if(tastatur.oben()){
        kamera.verschiebe(0,0,-1);
        } 
       if(tastatur.tab()){
        kamera.verschiebe(0,-1,0);
        }
       if(tastatur.shift()){
        kamera.verschiebe(0,1,0);
        }
       if(tastatur.istGedrueckt('l')){
         Sys.warte(1);
      MeinHaus.Licht_an();
       } 
     }
    } 
---------

public void Licht_an(){
    for(int i=0; i<4; i++){
       gartenlampelinks[i].setzeFarbe(1,1,0);
       gartenlamperechts[i].setzeFarbe(1,1,0);
   }
    for(int i=0; i<=1; i++){
        gartenlampeoben[i].setzeFarbe(1,1,0);
   }

}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...