This site requires JavaScript, please enable it in your browser!
Greenfoot back
MR.X
MR.X wrote ...

2013/9/20

Export Project Mistake

MR.X MR.X

2013/9/20

#
Hey, I have created a little zelda remake. I tried to export it to a application. If I open the application, it only shows this: Picture I hope, you can help me ;) Thank you! Code: ZeldaRmk
danpost danpost

2013/9/20

#
Please post the code to your initial world (at least the fields, constructor, and any methods that are run during the execution of the constructor.
MR.X MR.X

2013/9/20

#
Its very much, but I uploaded it her: Code
danpost danpost

2013/9/20

#
Please copy/paste it here (use the code link below the reply box).
MR.X MR.X

2013/9/20

#
main World:
public Welt()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1); 
        herzen[0] = new Herz(0);
        herzen[1] = new Herz(0);
        herzen[2] = new Herz(0);
        herzenS[0] = 0;
        herzenS[1] = 0;
        herzenS[2] = 0;
        todZahl = 0;
        
        loadLevel(4, new Figur(this));
    }
public void loadLevel(int l, Figur fi){
       
        int y = 25;
        int fX = 300;
        int fY = 300;
        if(!getObjects(Figur.class).isEmpty()){
            fX = fi.getX();
            fY = fi.getY();
        }
        
        switch(l){
            case 0:{
                level +=3;
                fY = 6;
            }break;
            case 1:{
                level +=1;
                fX = 6;
            }break;
            case 2:{
                level -=3;
                fY = 394;
            }break;
            case 3:{
                level -=1;
                fX = 594; 
            }break;
            default:{
                level = 4;
                fX = 300;
                fY = 300;
            }break;
        }
        
        removeObjects(getObjects(null));
        for(int i = 0; i < lvl[0].length; i++){
            if(i%12 == 0 && i!=0){                
                y+=50;
                Greenfoot.delay(1);
            }
            switch(lvl[level][i]){
                case 0:{                   
                    addObject(new Boden(1),((i%12)*50)+25,y);
                }break;
                
                case 1:{                   
                    addObject(new Mauer(1),((i%12)*50)+25,y);
                }break;
                
                case 2:{
                     addObject(new Mauer(2),((i%12)*50)+25,y);
                }break;
                
                case 3:{
                     addObject(new Mauer(3),((i%12)*50)+25,y);
                }break;
                
                case 4:{
                     addObject(new Boden(2),((i%12)*50)+25,y);
                }break;
                
                default: break;
            }                        
        }
        
        switch(level){
            case 0:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 1:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }
                    }
                    
                }
            }break;
            
            case 2:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 3:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 4:{
                addObject(new Schild("Seid wilkommen, ihr seid sicher gekommen, um die Prinzessin zu retten!!! Hierf\u00FCr musst du nur alle Teile des misteri\u00F6sen ... finden (:"), 400, 300);
                if(gegner[level]){
                    
                }
            }break;
            
            case 5:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 6:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 7:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 1){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 8:{
                
                if(gegner[level]){
                    
                }
            }break;
        }
        
        addObject(fi, fX, fY);
        
        
        
        
        
        
        
        
        for(int i = 0; i < herzen.length;i++){
            if(herzen[i] != null){
                addObject(herzen[i], 25+i*50, 25);
            }
        }
        /*
        addObject(new Herz(0), 25,25);
        addObject(new Herz(0), 75,25);
        addObject(new Herz(0), 125,25);
        */
    }
Mauer:
public Mauer(int a){
        switch(a){
            case 1:{
                setImage("Baeume.png");
                //setImage("Sand.png");
            }break;
            case 2:{
                setImage("Blaetter.png");
                //setImage("Sand.png");
            }break;
            case 3:{
                setImage("Mauer.png");
                //setImage("Sand.png");
            }break;
            case 4:{
                //setImage("Blätter.png");
                //setImage("Sand.png");
            }break;
            case 5:{
                //setImage("Blätter.png");
                //setImage("Sand.png");
            }break;
            default: break;
        }        
    }
Figur:
public Figur(Welt w){
        welt = w;
        d = 4;
        lastS = 0;
        lastL = 0;
        leben = 2;
        img = 1;
        schild = false;
        setImage("Figur01.png");
    }
Herz:
public Herz(int m){
        imgC(m);
    }
public void imgC(int i){
        switch(i){
            case 0:{
                setImage("Herz0.png");    
            } break;
            case 1:{
                setImage("Herz1.png");    
            } break;
            case 2:{
                setImage("Herz2.png");    
            } break;
            default: break;
        }
    }
danpost danpost

2013/9/20

#
You forgot to include the fields with the methods and constructors.
MR.X MR.X

2013/9/20

#
I dont know what you mean, but here is all the code: I hope it helps ;)
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Welt here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Welt extends World
{
    
    private int lvl[][] = {{2,1,1,1,1,1,1,2,1,1,1,2,
                            2,0,0,0,0,0,0,2,0,0,0,2,
                            2,0,0,1,0,1,0,2,0,0,0,1,
                            2,0,0,0,0,0,0,2,0,0,0,0,
                            2,0,0,0,2,1,1,1,0,0,0,0,
                            2,0,0,0,1,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            1,1,1,1,1,0,0,1,1,1,1,1},
                            
                           {2,2,1,1,1,1,1,1,1,1,2,2,
                            2,1,0,0,0,0,0,0,0,0,1,2,
                            1,0,0,0,0,0,0,0,0,0,0,1,
                            0,0,0,2,0,0,0,0,2,0,0,0,
                            0,0,0,1,0,0,0,0,1,0,0,0,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            2,2,0,0,0,0,0,0,0,0,2,2,
                            1,1,1,1,1,1,0,0,0,1,1,1},
                            
                           {2,2,1,1,1,1,1,1,1,1,2,2,
                            2,1,0,0,0,0,0,0,0,0,1,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            0,0,0,0,0,0,0,0,0,0,0,2,
                            0,0,0,0,0,2,1,1,1,1,1,2,
                            2,0,0,0,0,2,0,0,0,0,0,2,
                            2,2,0,0,0,2,0,0,0,0,0,2,
                            1,1,1,1,1,1,1,1,0,0,0,1},
                            
                           {2,2,1,1,1,0,0,1,1,1,2,2,
                            2,1,0,0,0,0,0,0,0,0,1,2,
                            2,0,0,2,0,2,2,0,2,0,0,2,
                            2,0,0,1,0,2,2,0,1,0,0,2,
                            2,0,0,0,0,1,1,0,0,0,0,2,
                            2,0,0,1,0,0,0,0,1,0,0,2,
                            2,2,0,0,0,0,0,0,0,0,2,2,
                            1,1,0,0,0,1,1,1,1,1,1,1},
                            
                           {2,2,2,2,2,2,0,0,0,1,1,2,
                            2,2,2,2,2,2,0,0,0,0,0,2,
                            2,2,2,2,2,2,0,0,0,0,0,1,
                            2,1,1,1,1,1,1,1,2,0,0,0,
                            2,0,0,0,0,0,0,0,1,0,0,0,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            1,1,1,1,1,1,1,1,1,1,1,1},
                            
                           {2,1,1,1,1,1,1,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            1,0,1,0,0,0,0,0,0,0,0,2,
                            0,0,0,0,2,0,0,2,0,0,2,2,
                            0,0,0,0,1,0,0,1,0,0,1,2,
                            2,0,1,0,0,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            1,1,1,1,1,1,1,1,1,0,0,1},
                            
                           {2,2,0,0,0,1,1,1,2,1,1,2,
                            2,1,0,0,0,0,0,0,2,0,0,2,
                            2,0,0,0,0,0,0,0,2,0,0,1,
                            2,0,0,1,1,1,1,1,2,0,0,0,
                            2,0,0,0,0,0,0,1,1,0,0,0,
                            2,1,1,1,1,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            1,1,1,1,1,1,1,1,1,1,1,1},
                            
                           {2,1,1,1,1,1,1,1,1,1,1,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,3,3,0,2,
                            1,0,0,0,0,0,0,0,4,3,0,2,
                            0,0,0,0,0,0,0,0,4,3,0,2,
                            0,0,0,0,0,0,0,0,3,3,0,2,
                            0,0,0,0,0,0,0,0,0,0,0,2,
                            1,1,1,1,1,1,1,1,1,1,1,1},
                        
                           {2,2,1,1,1,1,1,1,1,0,0,2,
                            2,1,0,0,0,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            2,0,0,0,0,0,0,0,0,0,0,2,
                            1,1,1,1,1,1,1,1,1,1,1,1}};

                      
                            
    private boolean gegner[] = {true, true, true, true, true, true, true, true, true};                        
    private int level;
    private int todZahl;
    private Herz herzen[] = new Herz[6];
    private int herzenS[] = new int[6];
    
    public Welt()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1); 
        herzen[0] = new Herz(0);
        herzen[1] = new Herz(0);
        herzen[2] = new Herz(0);
        herzenS[0] = 0;
        herzenS[1] = 0;
        herzenS[2] = 0;
        todZahl = 0;
        
        loadLevel(4, new Figur(this));
    }
    
    public void act(){
        if(Greenfoot.isKeyDown("enter")){
            Greenfoot.setWorld(new Menu(this));
        } 
       if(getObjects(Spawn.class).isEmpty()){
            gegner[level] = false;
        }
    }
    
    public void endScreen(){
        //play Sound tod;
        Greenfoot.setWorld(new NeuMenu(this, todZahl));
    }
    
    public void loadLevel(int l, Figur fi){
       
        int y = 25;
        int fX = 300;
        int fY = 300;
        if(!getObjects(Figur.class).isEmpty()){
            fX = fi.getX();
            fY = fi.getY();
        }
        
        switch(l){
            case 0:{
                level +=3;
                fY = 6;
            }break;
            case 1:{
                level +=1;
                fX = 6;
            }break;
            case 2:{
                level -=3;
                fY = 394;
            }break;
            case 3:{
                level -=1;
                fX = 594; 
            }break;
            default:{
                level = 4;
                fX = 300;
                fY = 300;
            }break;
        }
        
        removeObjects(getObjects(null));
        for(int i = 0; i < lvl[0].length; i++){
            if(i%12 == 0 && i!=0){                
                y+=50;
                Greenfoot.delay(1);
            }
            switch(lvl[level][i]){
                case 0:{                   
                    addObject(new Boden(1),((i%12)*50)+25,y);
                }break;
                
                case 1:{                   
                    addObject(new Mauer(1),((i%12)*50)+25,y);
                }break;
                
                case 2:{
                     addObject(new Mauer(2),((i%12)*50)+25,y);
                }break;
                
                case 3:{
                     addObject(new Mauer(3),((i%12)*50)+25,y);
                }break;
                
                case 4:{
                     addObject(new Boden(2),((i%12)*50)+25,y);
                }break;
                
                default: break;
            }                        
        }
        
        switch(level){
            case 0:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 1:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }
                    }
                    
                }
            }break;
            
            case 2:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 3:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 4:{
                addObject(new Schild("Seid wilkommen, ihr seid sicher gekommen, um die Prinzessin zu retten!!! Hierf\u00FCr musst du nur alle Teile des misteri\u00F6sen ... finden (:"), 400, 300);
                if(gegner[level]){
                    
                }
            }break;
            
            case 5:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 6:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 2){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 7:{
                
                if(gegner[level]){
                    while(getObjects(Spawn.class).size() < 1){
                        int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            addObject(new Spawn(), gX, gY);
                        }                       
                    }
                }
            }break;
            
            case 8:{
                
                if(gegner[level]){
                    
                }
            }break;
        }
        
        addObject(fi, fX, fY);
        
        
        
        
        
        
        
        
        for(int i = 0; i < herzen.length;i++){
            if(herzen[i] != null){
                addObject(herzen[i], 25+i*50, 25);
            }
        }
        /*
        addObject(new Herz(0), 25,25);
        addObject(new Herz(0), 75,25);
        addObject(new Herz(0), 125,25);
        */
    }
    
    public void addNewHerz(){
        
        int i = 0;
        while(herzen[i] != null && i <= herzen.length){ // evtl length -1
            i++;
        }
        if(i <= herzen.length){
            herzen[i] = new Herz(0);
            herzenS[i] = 0;
            addObject(herzen[i], 25+i*50, 25);
        }
    }
    
    
    public void lebenCheck(int l){
        if(l < herzen.length){
            for(int i = 5; i> l; i--){
                if(herzen[i] != null){
                    herzen[i].imgC(2);
                }
            }
        } 
            
        
        for(int i = 0; i < l; i++){
            herzen[i].imgC(0);
        }
    }
    public int maxLeben(){
        int temp = 0;
        for(int i = 0; i < herzen.length; i++){
            if(herzen[i] != null){
                temp++;
            }
            
        }
        return temp-1;
    }
    public void neuStart(){
        Figur f =(Figur) getObjects(Figur.class).get(0);
                
        loadLevel(5, f);
        f.setLeben(2);
        for(int i = 0; i<gegner.length;i++){
            gegner[i] = true;
        }
        herzen[0].imgC(0);
        herzen[1].imgC(0);
        herzen[2].imgC(0);
    }
}
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class TextZelle here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class TextZelle extends Actor
{
    private boolean on;
    
    public TextZelle(){
        on = false;
    }
    public void act() 
    {
    }   
    
    public void textZ(String t){
        if(!getNeighbours(20, false, Figur.class).isEmpty() && on == false)
        {
            on = true;
            getWorld().addObject(new Text(t), 300, 350);            
        } else if(getNeighbours(20, false, Figur.class).isEmpty()){
            getWorld().removeObjects(getWorld().getObjects(Text.class));
            on = false;
        }
        
    }
}
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Schild here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Schild extends TextZelle
{
    String text;
    public Schild(String t){
        text = t;
    }
    public void act() 
    {
        textZ(text);
    }    
}
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Figur here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Figur extends Actor
{
    private Welt welt;
    private int d;
    private long lastS, lastL, lastSch;
    private int leben;
    private short img;
    private boolean schild;
    
    public Figur(Welt w){
        welt = w;
        d = 4;
        lastS = 0;
        lastL = 0;
        leben = 2;
        img = 1;
        schild = false;
        setImage("Figur01.png");
    }
    public void act() 
    {
       
            bewegen();
            level();
            lebenCheck();
            
            if(System.currentTimeMillis() - lastL >= 1000 && schild){
                schild = false;
            }
            if(schild){
                setImage("Figur00.png");
            } else {
                setImage("Figur01.png");
            }
            /*
            if(!schild && img != 0){
                setImage("Spieler0.png");
            }
            while(schild){
                if(System.currentTimeMillis() - lastSch >= 200){
                    if(img == 0){
                        setImage("Spieler1.png");
                    } else {
                        setImage("Spieler0.png");
                    }
                }
            }
            */
            
    }    
    
    public void bewegen()
    {
        
        if(Greenfoot.isKeyDown("up") && noCollision(0,-5))
        {
            setLocation(getX(),getY()-2);
            //d = 0;
        }
        if(Greenfoot.isKeyDown("down") && noCollision(0,23))
        {
            setLocation(getX(),getY()+2);
            //d = 2;
        }        
        if(Greenfoot.isKeyDown("left") && noCollision(-24,0))
        {
            setLocation(getX()-2,getY());
            //d = 3;
        }
        if(Greenfoot.isKeyDown("right") && noCollision(23,0))
        {
            setLocation(getX()+2,getY());
            //d = 1;
        } 
        
        if(Greenfoot.isKeyDown("space") && System.currentTimeMillis() - lastS >= 500)
        {
            lastS = System.currentTimeMillis();
            //welt.addObject(new Bumerang(), getX(), getY());
            int gX = (int)(Math.random()*500+50);
                        int gY = (int)(Math.random()*300+50);
                                       
                        if(welt.getObjectsAt(gX, gY, Mauer.class).isEmpty()){
                            welt.addObject(new Gegner01(), gX, gY);
                        }
            //d = 1;
        } 
        
        /*
        if(Greenfoot.isKeyDown("space") && System.currentTimeMillis() - lastS >= 500)
        {
            lastS = System.currentTimeMillis();
            welt.addObject(new Schwert(d), getX(), getY());
        }
        
       
        switch(d) {
            case 0:{
                setLocation(getX() , getY()- 2);
            } break;
            case 1:{
                setLocation(getX()+ 2, getY() );
            } break;
            case 2:{
                setLocation(getX() , getY()+ 2);
            } break;
            case 3:{
                setLocation(getX()- 2, getY() );
            } break;
            default: break;
        }       
        d = 4;
        */
       if(Greenfoot.isKeyDown("w") && System.currentTimeMillis() - lastS >= 500){
           lastS = System.currentTimeMillis();
           welt.addObject(new Schwert(0), getX(), getY());
        }
        if(Greenfoot.isKeyDown("d") && System.currentTimeMillis() - lastS >= 500){
           lastS = System.currentTimeMillis();
           welt.addObject(new Schwert(1), getX(), getY());
        }
        if(Greenfoot.isKeyDown("s") && System.currentTimeMillis() - lastS >= 500){
           lastS = System.currentTimeMillis();
           welt.addObject(new Schwert(2), getX(), getY());
        }
        if(Greenfoot.isKeyDown("a") && System.currentTimeMillis() - lastS >= 500){
           lastS = System.currentTimeMillis();
           welt.addObject(new Schwert(3), getX(), getY());
        }
    }
    
    public void level(){
        if(getX() >= 595){
            welt.loadLevel(1, this);
        } else if(getX() <= 5){
            welt.loadLevel(3, this);
        } else if(getY() >= 395){
            welt.loadLevel(0, this);
        } else if(getY() <= 5){
            welt.loadLevel(2, this);
        }
    }
    
    public boolean noCollision(int dx, int dy){
        
        if(getOneObjectAtOffset(dx, dy, Mauer.class) != null)
        {
            return false;
        } else {
            return true;
        }
    }
    
    public void lebenCheck(){
        
        
        if(getOneIntersectingObject(Gegner.class) != null && System.currentTimeMillis() - lastL >= 1000){
            
            schild = true;
            lastL = System.currentTimeMillis();
            leben --;
            welt.lebenCheck(leben);
        }
        if(getOneIntersectingObject(HerzItem.class) != null){
            if(leben < welt.maxLeben()){
                
                leben++;
            }
            welt.lebenCheck(leben+1);
            welt.removeObject(getOneIntersectingObject(HerzItem.class));
        }
        if(leben < 0){
            welt.endScreen();
        }
    }
    
    public void setLeben(int l){
        leben = l;
        //welt.lebenCheck(leben);
    }
}
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Baum here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Mauer extends Actor
{
    /**
     * Act - do whatever the Baum wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    
    public Mauer(int a){
        switch(a){
            case 1:{
                setImage("Baeume.png");
                //setImage("Sand.png");
            }break;
            case 2:{
                setImage("Blaetter.png");
                //setImage("Sand.png");
            }break;
            case 3:{
                setImage("Mauer.png");
                //setImage("Sand.png");
            }break;
            case 4:{
                //setImage("Blätter.png");
                //setImage("Sand.png");
            }break;
            case 5:{
                //setImage("Blätter.png");
                //setImage("Sand.png");
            }break;
            default: break;
        }        
    }
}

import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Boden here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Boden extends Actor
{
    public Boden(int a){
        switch(a){
            case 1:{
                setImage("Gras.png");
            }break;
            case 2:{
                setImage("Treppe.png");
            }break;
        }
        
    }
    public void act() 
    {
        // Add your action code here.
    }    
}
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Herz here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Herz extends Actor
{
    public Herz(int m){
        imgC(m);
    }
    public void act() 
    {
        // Add your action code here.
    }   
    
    public void imgC(int i){
        switch(i){
            case 0:{
                setImage("Herz0.png");    
            } break;
            case 1:{
                setImage("Herz1.png");    
            } break;
            case 2:{
                setImage("Herz2.png");    
            } break;
            default: break;
        }
    }
}
danpost danpost

2013/9/20

#
I cannot tell what the problem you are having is. I copy/pasted the classes into a new scenario, commented out sections unrelated to the initialization of the world, exported it as an application --- and I had no problems with the application.
MR.X MR.X

2013/9/21

#
Mhh... :/ In the Greenfoot Gallery it works... ZeldaRmk
You need to login to post a reply.