This site requires JavaScript, please enable it in your browser!
Greenfoot back
Back to discussions
Gulliver
Gulliver wrote ...

2017/4/21

A Question from Greenfoot newbie

Gulliver Gulliver

2017/4/21

#
I just downloaded and installed Greenfoot, I was going to open an example project and follow the instructional video about it. All was Ok until I was taught that after has been made a change, I had to compiled it. But surprisingly my installed Greenfoot interface is different from the showed in the video. Mine do not have a Compile button at the end of Act Run Reset Spedd toolbar. I thought that I have had a an installation problem so I unistalled and Installed it again, but nothing changed, however I know that something is missing, because in the practical part, we had to create new methods but the fact that they are not executed indicates that despite the matter of compilig the class on every change made to it, those changes are not registered ┬┐What can I do? I would appreciate any help. Thanks in advance
davmac davmac

2017/4/21

#
Since Greenfoot 3.0, compilation is automatic. You do not need to hit the compile button anymore. The changes should register automatically. If you think that your changes are not taking effect, please show your code and explain what you think should be happening and what is happening instead.
Gulliver Gulliver

2017/4/21

#
Thanks a lot for your answer. The problem I talked about in my post is still there, that is I create a new method, but It is not executed when I run the project. I am still a little bit disoriented, yesterday after any chamge did to the class code I clicked on Compile button in the Code Editor, today I tried with the Reset Button in the project execution window instead. They, both do the same, that is comile the cclass. It seems to me that the Compile Button in Grefoot versions previous to 3.0.0 was replaced by Reset Button. The only strange thing that I can write about was a windows message prompting about the version of the project 2.6.0 and would let me to choose if allows an automatically updated to 3.0.0 or later on manually, I chose the automatically. The only warning was about the replacement of java-awt.classes with grennfoot.Color and greenfoot.Font.
/**
     * Move the car forward every time the key "up" is pressed
     */
    public void moveForward(){
        if (Greenfoot.isKeyDown("up")){
            move(5);
        }
    } 
    /**
     * Move the car forward, but 2 times faster than the normal moveForward method
     */
    
    public void useTurbo(){
        if (Greenfoot.isKeyDown("t")){
            move (10);
        }
        
    }
    
    /**
     * Move the car back every time the key "down" is pressed
     */
    public void moveBack(){
        if (Greenfoot.isKeyDown("down")){
            move(-1);
        }
    }  
The new method is useTurbo() which should move the the Car, 2 times faster, than the moveForward, by pressing the "t" key but nothing happens when I press it. Thanks in advance
Super_Hippo Super_Hippo

2017/4/21

#
Do you call it from the act method? By the way, the reset button does not compile your project (= no reset of static variables).
davmac davmac

2017/4/22

#
Right, you have a method - but is it ever called? Methods don't get called automatically, except for act() and one or two other special methods.
Gulliver Gulliver

2017/4/22

#
Thanks a lot for the answers, The problem was resolved once I registered the new method in the act(). I think it is part of being a newbie. Next question I hope not to be as silly as this first one
You need to login to post a reply.