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
davmac davmac

2012/5/18

#
martijn13039, you wrote that line of code yourself. So: tell us what it is meant to do...
martijn13039 martijn13039

2012/5/18

#
Davmac I want to make à menu and that THE game start when i puss on that menu(pictiur) and trash i hope you can help me to make this method becaus i've no idea i think i've a blackout ore something like that
davmac davmac

2012/5/18

#
What is that particular line of code meant to do?
davmac davmac

2012/5/18

#
Perhaps call setMenuItem in the actor instead of trying to call it on the world?
martijn13039 martijn13039

2012/5/18

#
I'm sorry for this respond but i dont understand what you mean, i hope you can explain it again on a other way
trash1000 trash1000

2012/5/18

#
Instead of
World2 mw = (World2) getWorld();    
  
mw.setMenuItem(caption);
try it with
setMenuItem(caption)
So that you do not call a method from world that does not exist.
martijn13039 martijn13039

2012/5/19

#
hey trash1000 there are no errors but i can´t put my actor (pictur == menu) in the game because there come something that need to start string text i want that if i put on that pictur the game start so that my clock not is counting down for i put on that pictur
danpost danpost

2012/5/19

#
The main problem is, and has been, that the code I supplied was not placed in the location I stated to put it. All the errors were due to this fact. I had once, already, stated that this was the problem, and it is still not resolved. Ignore my code post of 5/12/12, as I had assumed it was properly placed, and did not check to make sure. The code I wrote there was based on the code that was returned (which was placed in the subclass of Actor 'Start' class) after my original posting of that code (which stated to put it in the world class). I had corrected the error that was being recieved at that time and did not notice the fact of its incorrect location.
martijn13039 martijn13039

2012/5/19

#
but danpost how can I fix this, I wil explain again wat i want and i hope you understand it better I want a pictur (make by my self) thats is menu, and when i puss on the pictur it go way and the game start. I don't want actors walking behind de pictur, but if i put on the picturs that the actors go walking. I hope dat you understand me
danpost danpost

2012/5/19

#
Please re-read carefully my post of 5/9/12 that contains the code in question. Line 10 of that code explains where to add the main actors for your game into the world. That is also where you would start the counter (I believe you mentioned something about starting a counter after the menu item was selected). As far as actors walking behind the picture, remember, you will not be adding them to the world until after the picture was clicked on and the menu was removed.
martijn13039 martijn13039

2012/5/19

#
this is the code you mean but it don;t work there are errors cannont find symbol- method getobjectsjave.lang.class menu
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;
}
}
danpost danpost

2012/5/19

#
Of course it does not work! You have it in an Actor class, not in your class that extends World.
martijn13039 martijn13039

2012/5/19

#
danpost i got this now but there are no errors but if i puss on the pictur nothing happend (like if i put on the pictur nothing happend
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

public class World2 extends World
{
    public boolean Start;
    /**
     * Constructor for objects of class loll.
     * 
     */
    public World2()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        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;
}
}
danpost danpost

2012/5/19

#
Now, you put your prepare method at line 26 (add all the objects and start the timer, etc.). See lines 9 and 10 of the code I posted on 5/9/12.
martijn13039 martijn13039

2012/5/19

#
very stupid question but how can I att that objects srry stupid question but I have no idea
There are more replies on the next page.
1
2
3
4
5