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

2012/11/18

How to let Greenfoot wait?

1
2
3
SPower SPower

2012/11/19

#
It is:
Greenfoot.isKeyDown("space")
not
isKeyDown("space")
:0
Sl3nDeRm4n Sl3nDeRm4n

2012/11/19

#
yes i wrote Greenfoo.isKeyDown but it doesnot work with space. it only worked with n or an other letter
SPower SPower

2012/11/19

#
Weird...
danpost danpost

2012/11/19

#
Maybe "space" is a hotkey on your system???
Sl3nDeRm4n Sl3nDeRm4n

2012/11/19

#
i think the space bar has another name but that shouldnt be the problem on my code
danpost danpost

2012/11/19

#
From the sounds of it, it probably does have something to do with the particular type of system you are using or the way it is set up.
Sl3nDeRm4n Sl3nDeRm4n

2012/11/19

#
i have a much bigger problem in my game: i put objects in my world wich moves in the world from one point to another and back in a line. I solved that like this:
    public void act( ) 
    {
        
        if(place == true){
            move(1);
        }
        if(place == false){
            move(-1);
        }
        if(getX()>695){
            place = false;
        }
        if(getX()<455){
            place = true;
        }
    }    
but this works only if i paste the object between these 2 x coordinates. Is it possible to replace the 2 numbers with two parameters x1 and x2 which are given to a created actor of this class when i create it?
danpost danpost

2012/11/19

#
Of course:
// add the following instance variable to the class
int minX, maxX;
// change constructor declaration to
public ObjectName(int loX, int hiX)
// add to the constructor
minX = loX;
maxX = hiX;
// change 695 and 455 in your code above
// to maxX and minX
Then when you create an object, use (for the above)
new ObjectName(455, 695)
Sl3nDeRm4n Sl3nDeRm4n

2012/11/19

#
ok thank you
Sl3nDeRm4n Sl3nDeRm4n

2012/11/19

#
        MoveDead move = new MoveDead(455, 695);
        addObject(new MoveDead(455,695),456, 545);
Do you mean like this in my world class?
SPower SPower

2012/11/19

#
This would be non-weird:
MoveDead move = new MoveDead(455, 695);
addObject(move,456, 545);
:)
Sl3nDeRm4n Sl3nDeRm4n

2012/11/19

#
ok thx now i did it like this but greenfoot doesnt load the world after i compiled...
danpost danpost

2012/11/19

#
Or just
addObject(new MoveDead(455, 695), 456, 545);
without the
MoveDead move = new MoveDead(455, 695);
before it.
Sl3nDeRm4n Sl3nDeRm4n

2012/11/19

#
no i restarted Greenfoot and now it worked dont know what happend:D Thank you
SPower SPower

2012/11/19

#
That's a bug in greenfoot :)
There are more replies on the next page.
1
2
3