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

2012/5/8

Is there a contrary from this code

1
2
3
4
5
martijn13039 martijn13039

2012/5/20

#
have you an idea? or not?
danpost danpost

2012/5/20

#
Only you would know what you are trying to do. I have no clue!
martijn13039 martijn13039

2012/5/20

#
how do you mean i don't know how I can put that in (i have code for the time and so but need i the whole code in this code or how)
martijn13039 martijn13039

2012/5/21

#
plz helpm me i have really no idea plz
davmac davmac

2012/5/21

#
martijn13039: It's clear that you just don't understand some quite basic concepts of Java programming. The solution is to learn them - not to just pester people until they write the code for you. Read through the Greenfoot tutorials, and perhaps do a Google search for Java programming tutorials. And, if you need help afterwards, take the effort to think about and explain your problems fully.
martijn13039 martijn13039

2012/5/21

#
I say it again, i´m not the best one in greenfoot but wat you say is not true, I always try to make codes with greenfoot help site and the greenfoot book (in the book stay not a much) but i only ask you how do you mean to at objects in the code but I don't ask you for the code but only how to at objects but if you don't want to help plz don't react
davmac davmac

2012/5/21

#
but i only ask you how do you mean to at objects in the code but I don't ask you for the code but only how to at objects
Ok, I understand there may be a bit of a language barrier here. What do you mean by 'at objects in the code'? This doesn't make sense to me.
martijn13039 martijn13039

2012/5/22

#
davmac srry for my irrated post. I like to make a menu in the game that i have make. the menu is an pictur that i maked in photoshop and I want if i put on that pictur with my mouse that de pictur dissapear and that the game start. I know the code for remove the pictur ect. but the issue is that my actors are walking and the clock is counting down before i have put on the picture danpost and trash1000 have helping me to make a code for that but in this code stay at your obbjects but i don´t know what it mean (maby the languag barrier is an problem but I can't find nothing on internet and in the book about this i hope you can help me
import greenfoot.*;

public class Menu extends Actor
{
   private String menuItem = "";
private boolean menuDone = false;

public void act()
{
    if (!menuDone && !"".equals(menuItem))
    {
        removeObjects(getObjects(Menu.class));
        // set up background for game
        // add objects for game
        menuDone = true;
    }
    //  rest of act (for game play)
}

public void setMenuItem(String muItem)
{
    menuItem = muItem;
}
}
davmac davmac

2012/5/22

#
You need a boolean, probably an instance variable in the world, to keep track of whether the menu has been clicked or not. All the actors should check it before they act - if the menu hasn't been clicked, the actors should do nothing. When the menu is clicked it should tell the world to set the variable.
martijn13039 martijn13039

2012/5/22

#
excextly that is what I mean but need I put the full code from, let say the clock in this code or how do you mean or something like this: removeObjects(getObjects(Menu.class)); if { (Greenfoot.mouseClicked(time)) }
danpost danpost

2012/5/22

#
@davmac, the value of 'menuItem' was supposed to be a world instance variable to recieve the clicked on menu object. martijn13039 has the incorrect code in the Menu (actor) class and has been told about it several times. Also, 'menuDone' was supposed to be in the world class to indicate that the menu part of the scenario was finished and the game characters could now be created and added to the world. If you would read the entire discussion you will understand what I am talking about.
martijn13039 martijn13039

2012/5/22

#
I'm really confused Now, what is wrong plz explain it me I want that if i put on THE pictur THE picture remove and THE game START
martijn13039 martijn13039

2012/5/22

#
Oow srry double post
davmac davmac

2012/5/22

#
... the value of 'menuItem' was supposed to be a world instance variable to recieve the clicked on menu object
Yes, I understand what you were doing.
martijn13039 has the incorrect code in the Menu (actor) class and has been told about it several times
Yes, I know that too. I'm at a bit of a loss with how to proceed with that line though; martijn13039 clearly doesn't understand what he's meant to do. martijn13039:
... need I put the full code from, let say the clock in this code or how do you mean
Sorry, but that makes no sense to me at all. You don't need to put from any clock anywhere. You need to have a variable in your world which controls whether the game has started or not. Have you got this? What is the variable called? Can you post the code for your world?
martijn13039 martijn13039

2012/5/22

#
Davmac this is my world code, and i think i haven´t a variable in my world
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)


public class World2 extends World
{
    public boolean Start;
    
    public World2()
    {    
      
        super(600, 400, 1); 
        
    }

  
private String menuItem = "";
private boolean menuDone = false;

public void act()
{
    if (!menuDone && !"".equals(menuItem))
    {
        removeObjects(getObjects(Menu.class));
        
        menuDone = true;
    }
    
}

public void setMenuItem(String muItem)
{
    menuItem = muItem;
}
}

There are more replies on the next page.
1
2
3
4
5