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

2018/12/18

Problem with "Greenfoot.mouseClicked"

1
2
3
danpost danpost

2018/12/18

#
Nahquin wrote...
yepp still wall just diferent number: Wall@45065
Alright, there must be a greenfoot bug with the paint order. Please show your World subclass code (the one with the wall and the button). We'll try a different approach.
Nahquin Nahquin

2018/12/18

#
public void End(){
        addObject(new End(),31/2, 31/2);
        showText("Megevett almák: "+ (a-1),13,10);
        showText("Lépések: "+ (l),12,12);
        addObject(new Restart(),15, 19);
    }
public void wall(){
        int[] f =new int[]{31,0,0,31,30,0};
        for (int i=0; i<f.length; i=i+3){
            f_falak(f[i],f[i+1],f[i+2]);
        }
        int [] v = new int[]{31,0,0,31,0,30};
        for (int i=0; i<v.length; i=i+3){
            v_falak(v[i],v[i+1],v[i+2]);
        }
    }
    public void f_falak(int n, int x, int y){
        for(int i=0; i<n; i++){
            Wall kocka= new Wall();
            addObject(kocka,x,i+y);
        }
    }
    public void v_falak(int n, int x, int y){
        for(int i=0; i<n; i++){
            Wall kocka= new Wall();
            addObject(kocka,i+x,y);
        }
    }
I dont use End(); in the world just in Snake.class like:
public void kocc_wall(){
        Actor w = getOneIntersectingObject(Wall.class);
        if (w != null){
            SnakeW W = (SnakeW)getWorld();
            W.End();
            kocc=true;
        }
    }
danpost danpost

2018/12/18

#
Nahquin wrote...
<< Codes Omitted >> I dont use End(); in the world just in Snake.class like: << Code Omitted >>
Need the constructor (at minimum) -- and methods called from there.
Nahquin Nahquin

2018/12/18

#
what is constructor ?
danpost danpost

2018/12/18

#
Nahquin wrote...
what is constructor ?
The method without a return type. The first line in a World type constructor usually starts with 'super(...'.
Nahquin Nahquin

2018/12/18

#
public SnakeW()
    {    
        super(31, 31, 25); 
        wall();
        addObject(new Snake(),15,15);
        //addObject(new Animation(),15,15);
        Alma();
        
    }
?
danpost danpost

2018/12/18

#
Nahquin wrote...
<< SnakeW Constructor Omitted >> ?
Yes. Oh, but now I see what you meant by the comment on the End method. Out of curiosity (maybe something), what does the newSize method look like in your Restart class?
Nahquin Nahquin

2018/12/18

#
public void newSize(int x)
    {// a hívó objektum méretét kicsinyíti x-edére
        GreenfootImage myImage = getImage();
        myImage.scale(myImage.getWidth() / x, myImage.getHeight() / x);
        setImage(myImage);         
    }  
danpost danpost

2018/12/18

#
Nahquin wrote...
<< Code Omitted >>
No problem there in newSize (I believe). You gave a method called kocc_Wall above (where you called the End method from). Change line 3 of that method to the following:
if (w != null && ! kocc) {
This may or may not do anything as far as mouse clicks are concerned.
Nahquin Nahquin

2018/12/18

#
still wall :|
danpost danpost

2018/12/18

#
Nahquin wrote...
still wall :|
Try manually removing the wall and testing it.
Nahquin Nahquin

2018/12/18

#
Ok so i did: //wall(); to check whats up without it and : Actor clicked: null Its looks like its dosnt even see the button is in the world
danpost danpost

2018/12/18

#
Try commentiing out the showText lines in the End method (just wondering).
Nahquin Nahquin

2018/12/18

#
Nothing
danpost danpost

2018/12/18

#
Nahquin wrote...
Nothing
Running out of things to try. Can you upload the game (or update it) so I can look at it for inspection and testing purposes?
There are more replies on the next page.
1
2
3