<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Greenfoot Discuss</title>
    <link>https://www.greenfoot.org/topics</link>
    <description>The latest Greenfoot discussion posts</description>
    <language>en-us</language>
    <item>
      <title>Reply to How do i make a Project to .jar</title>
      <description>And are u sure that it doesnt cause problems becaus its old? And if not which version should i download. thx for ur help</description>
      <author>Zildrion</author>
      <pubDate>Tue, 09 Jun 2026 08:26:56 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66669?pid=151026#post_151026</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;danpost wrote...&lt;/div&gt;&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;bonyay wrote...&lt;/div&gt;I think if this last error is solved, it will function?&lt;/div&gt;My mistake.  Line 28 should be:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;Greenfoot.setWorld(Dock.dock);&lt;/pre&gt;&lt;/div&gt;
My last edit to &lt;span class="bb_italic"&gt;change &lt;/span&gt;methods still stands as it should not matter which world is currently active here.  The referencing bypasses that issue.  And, it should have nothing to do with actor not in world as &lt;span class="bb_italic"&gt;act &lt;/span&gt;method is not executed when not in world.&lt;/div&gt;Between the time I posted that and your reply, I searched far and wide for a solution and ended up basically revamping a lot of the code. Good news though, everything works! I just have to write out the rest of the upgrades and everything, but I think that if I just repeat my template, then it&amp;amp;#39;ll be fine. &lt;span class="bb_bold"&gt;Thank you so, so much for all your help!&lt;/span&gt; (If you want to see what I did, I updated the scenario, also realized I accidentally had it uploaded twice so I took one down lol)

&lt;span class="bb_italic"&gt;(we aren&amp;amp;#39;t being graded on our code&amp;amp;#39;s efficiency, so honestly, it&amp;amp;#39;s the least of my concerns--as long as it works, I&amp;amp;#39;m satisfied for now)&lt;/span&gt;</description>
      <author>bonyay</author>
      <pubDate>Fri, 05 Jun 2026 02:29:36 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151024#post_151024</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;bonyay wrote...&lt;/div&gt;I think if this last error is solved, it will function?&lt;/div&gt;My mistake.  Line 28 should be:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;Greenfoot.setWorld(Dock.dock);&lt;/pre&gt;&lt;/div&gt;
My last edit to &lt;span class="bb_italic"&gt;change &lt;/span&gt;methods still stands as it should not matter which world is currently active here.  The referencing bypasses that issue.  And, it should have nothing to do with actor not in world as &lt;span class="bb_italic"&gt;act &lt;/span&gt;method is not executed when not in world.</description>
      <author>danpost</author>
      <pubDate>Fri, 05 Jun 2026 02:17:29 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151023#post_151023</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>Update:
In class, my instructor had said that part of my error was from not knowing if DockButton was in the world(or something like that). I didn&amp;amp;#39;t really get what he meant/why it would cause an error, but from what it sounded like to me, I had to check if the DockButton actor was in the world before coding anything with it.

 I added a check if it is, and now I am down to having only one error with two lines: 

&amp;amp;quot;java.lang.NullPointerException: Cannot read field &amp;amp;quot;dock&amp;amp;quot; because &amp;amp;quot;this.dock&amp;amp;quot; is null
	at DockButton.change(DockButton.java:28)
	at DockButton.act(DockButton.java:18)&amp;amp;quot;
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class DockButton here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class DockButton extends Buttons
{
    private Dock dock;
    /**
     * Act - do whatever the DockButton wants to do. This method is called whenever
     * the &amp;amp;#39;Act&amp;amp;#39; or &amp;amp;#39;Run&amp;amp;#39; button gets pressed in the environment.
     */
    public void act()
    {
        change();
    }
    public void change()
    {
        if(Greenfoot.mouseClicked(this) &amp;amp;amp;&amp;amp;amp; getWorld() instanceof Dock) 
        {
            Greenfoot.setWorld(dock);  
        }
        else if (Greenfoot.mouseClicked(this) &amp;amp;amp;&amp;amp;amp; getWorld() instanceof Shop &amp;amp;amp;&amp;amp;amp; (getWorld()!=null))
        {
            Greenfoot.setWorld(dock.dock);
        }
    }
    public DockButton(Dock _dock)
    {
        dock = _dock;
    }
}&lt;/pre&gt;&lt;/div&gt;I think if this last error is solved, it will function?</description>
      <author>bonyay</author>
      <pubDate>Fri, 05 Jun 2026 00:19:41 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151022#post_151022</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;danpost wrote...&lt;/div&gt;
It should not matter what world you are in:
&lt;/div&gt;
Yes, I had your code written originally but got an error (i cant remember exactly), i think it was something like &amp;amp;quot;this.dock is null&amp;amp;quot; so i added the instanceof code and it worked. I dont really understand how I could apply the same logic to the DockButton, though. I think I get the same error, but i cant check because im traveling home right now.

Edit: Alright, Im back home now and it did gives me the errors:
&amp;amp;quot;java.lang.NullPointerException: Cannot read field &amp;amp;quot;dock&amp;amp;quot; because &amp;amp;quot;this.dock&amp;amp;quot; is null

java.lang.NullPointerException: The given world cannot be null.

java.lang.ClassCastException: class Shop cannot be cast to class Dock (Shop and Dock are in unnamed module of loader java.net.URLClassLoader @67e92a&amp;amp;quot;

Which I believe are the same ones I got when using the code you gave me in the quoted reply? 

Honestly, I might have written something incorrectly from a previous reply of yours..? Updated scenario with the new code</description>
      <author>bonyay</author>
      <pubDate>Thu, 04 Jun 2026 20:23:35 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151021#post_151021</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;bonyay wrote...&lt;/div&gt;&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public void change()
{
    if(Greenfoot.mouseClicked(this) &amp;amp;amp;&amp;amp;amp; getWorld() instanceof Dock) 
    {
        Greenfoot.setWorld(dock);  
    }
    else if (Greenfoot.mouseClicked(this) &amp;amp;amp;&amp;amp;amp; getWorld() instanceof Shop)
    {
        Greenfoot.setWorld(dock.dock);
    }
}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;It should not matter what world you are in:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public void change() {
    if (Greenfoot.mouseClicked(this)) Greenfoot.setWorld(dock.dock);
}&lt;/pre&gt;&lt;/div&gt;This should be sufficient in the DockButton class.

And the following in the RoomButton class:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public void change() {
    if (Greenfoot.mouseClicked(this)) Greenfoot.setWorld(dock.room);
}&lt;/pre&gt;&lt;/div&gt;
And similarly for ShopButton class:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public void change() {
    if (Greenfoot.mouseCLicked(this)) Greenfoot.setWorld(dock.shop);
}&lt;/pre&gt;&lt;/div&gt;</description>
      <author>danpost</author>
      <pubDate>Thu, 04 Jun 2026 20:04:10 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151020#post_151020</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;bonyay wrote...&lt;/div&gt;Now movement between worlds should work.&lt;/div&gt;
So now, the switching from Dock to Shop or Room and switching from Room to Shop and vice versa is fully functional, but the problem is still moving from Shop or Room to Dock.
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public class ShopButton extends Buttons
{
    private Dock dock;
    /**
     * Act - do whatever the ShopButton wants to do. This method is called whenever
     * the &amp;amp;#39;Act&amp;amp;#39; or &amp;amp;#39;Run&amp;amp;#39; button gets pressed in the environment.
     */
    public void act()
    {
        change();
    }
    public void change()
    {
        if(Greenfoot.mouseClicked(this)  &amp;amp;amp;&amp;amp;amp; (getWorld() instanceof Dock))
        {
            Greenfoot.setWorld(dock.shop);
        }
        else if (Greenfoot.mouseClicked(this) &amp;amp;amp;&amp;amp;amp; (getWorld() instanceof Room))
        {
            Greenfoot.setWorld(new Shop());
        }
    }
    public ShopButton(Dock _dock)
    {
        dock = _dock;
    }
}&lt;/pre&gt;&lt;/div&gt;
Code below does not work:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;private Dock dock;
    /**
     * Act - do whatever the DockButton wants to do. This method is called whenever
     * the &amp;amp;#39;Act&amp;amp;#39; or &amp;amp;#39;Run&amp;amp;#39; button gets pressed in the environment.
     */
    public void act()
    {
        change();
    }
    public void change()
    {
        if(Greenfoot.mouseClicked(this) &amp;amp;amp;&amp;amp;amp; getWorld() instanceof Dock) 
        {
            Greenfoot.setWorld(dock);  
        }
        else if (Greenfoot.mouseClicked(this) &amp;amp;amp;&amp;amp;amp; getWorld() instanceof Shop)
        {
            Greenfoot.setWorld(dock.dock);
        }
    }
    public DockButton(Dock _dock)
    {
        dock = _dock;
    }
&lt;/pre&gt;&lt;/div&gt;</description>
      <author>bonyay</author>
      <pubDate>Thu, 04 Jun 2026 19:58:05 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151019#post_151019</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;danpost wrote...&lt;/div&gt;
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public class RoomButton extends Buttons
{
    private Dock dock;
    
    public RoomButton(Dock _dock) {
        dock = _dock;
    }
    
    public void act() {
        change();
    }
    
    public void change() {
        if (Greenfoot.mouseClicked(this)) {
            Greenfoot.setWorld(dock.room);
        }
    }
}&lt;/pre&gt;&lt;/div&gt;with:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;/**   In Dock class  */
RoomButton roomButton = new RoomButton(this);

/**  In Shop class  */
RoomButton roomButton = new RoomButton(dock);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
I&amp;amp;#39;ve implemented this code, and it works just fine for going from Dock to another World, but once at the other World you cannot change to any other, I&amp;amp;#39;m guessing because you are no longer starting at Dock? I have an idea, but I don&amp;amp;#39;t know if it&amp;amp;#39;ll mess anything up or if im even writing it correctly/its possible to use in this way: &lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public class RoomButton extends Buttons
{
    private Dock dock;
    /**
     * Act - do whatever the RoomButton wants to do. This method is called whenever
     * the &amp;amp;#39;Act&amp;amp;#39; or &amp;amp;#39;Run&amp;amp;#39; button gets pressed in the environment.
     */
    public void act()
    {
        change();
    }
    public void change()
    {
        if(Greenfoot.mouseClicked(this)) &amp;amp;amp;&amp;amp;amp; (World instanceof Dock) //i dont know exactly how to word or use this or if its even correct, ive never used instanceof before
        {
            Greenfoot.setWorld(dock.room);
        }
else if(Greenfoot.mouseClicked(this)) &amp;amp;amp;&amp;amp;amp; (World instanceof Shop)
{
 Greenfoot.setWorld(new Shop()); //if its slightly mistyped, ignore it, i dont have it exactly memorized
}
    }
    public RoomButton(Dock _dock)
    {
        dock = _dock;
    }
}&lt;/pre&gt;&lt;/div&gt;  If you know for certain the other way to do this, then you can send it. Thankfully, my instructor has extended the deadline to tomorrow! Also, I uploaded the updated version with the code you&amp;amp;#39;ve given me.

Edit: Hm, I tested out my idea and I&amp;amp;#39;m guessing I&amp;amp;#39;m just using &amp;amp;quot;instanceof&amp;amp;quot; incorrectly. Would it be more like &lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;getWorld()==Dock&lt;/pre&gt;&lt;/div&gt;Or something along the lines of. Im just trying to express my general idea, not fully correct code.

Second edit: ok i figured it out. its (getWorld() instanceof worldname). Lol. Updated code:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public class RoomButton extends Buttons
{
    private Dock dock;
    /**
     * Act - do whatever the RoomButton wants to do. This method is called whenever
     * the &amp;amp;#39;Act&amp;amp;#39; or &amp;amp;#39;Run&amp;amp;#39; button gets pressed in the environment.
     */
    public void act()
    {
        change();
    }
    public void change()
    {
        if(Greenfoot.mouseClicked(this) &amp;amp;amp;&amp;amp;amp; (getWorld() instanceof Dock))
        {
            Greenfoot.setWorld(dock.room);
        }
        if (Greenfoot.mouseClicked(this) &amp;amp;amp;&amp;amp;amp; (getWorld() instanceof Shop))
        {
            Greenfoot.setWorld(new Shop());
        }
    }
    public RoomButton(Dock _dock)
    {
        dock = _dock;
    }
}
&lt;/pre&gt;&lt;/div&gt;This doesnt give any errors, but the changing to Room from Shop doesnt work, both with and without &amp;amp;quot;&amp;amp;amp;&amp;amp;amp; (getWorld() instanceof Shop))&amp;amp;quot; on the second if statement and with and without &amp;amp;quot;else if&amp;amp;quot;. 

I JUST REALIZED I WAS CODING IT TO GO TO THE SHOP WORLD IM VERY TIRED. Now movement between worlds should work.</description>
      <author>bonyay</author>
      <pubDate>Thu, 04 Jun 2026 19:17:57 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151018#post_151018</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>I am guessing there is probably a better way to do all this, but it would require quite a bit of editing.

My idea was, now that you have one, and only one, &lt;span class="bb_italic"&gt;Room&lt;/span&gt;, &lt;span class="bb_italic"&gt;Dock&lt;/span&gt;, and &lt;span class="bb_italic"&gt;Shop &lt;/span&gt;object begin created, &lt;span class="bb_italic"&gt;static &lt;/span&gt;fields to retain references to them would now be suitable.  They can be each in their own class to make access to them really easy.  You wouldn&amp;amp;#39;t need to keep passing the Dock object reference all over the place.  Just make sure you create both other objects during the execution of the constructor of the initial world.
...
and that all three constructors each assign themselves (keyword:  &lt;span class="bb_italic"&gt;this&lt;/span&gt;) to their field.</description>
      <author>danpost</author>
      <pubDate>Thu, 04 Jun 2026 17:52:38 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151017#post_151017</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;bonyay wrote...&lt;/div&gt;&amp;amp;lt;&amp;amp;lt; RoomButton Class Codes Omitted &amp;amp;gt;&amp;amp;gt;&lt;/div&gt;&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public class RoomButton extends Buttons
{
    private Dock dock;
    
    public RoomButton(Dock _dock) {
        dock = _dock;
    }
    
    public void act() {
        change();
    }
    
    public void change() {
        if (Greenfoot.mouseClicked(this)) {
            Greenfoot.setWorld(dock.room);
        }
    }
}&lt;/pre&gt;&lt;/div&gt;with:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;/**   In Dock class  */
RoomButton roomButton = new RoomButton(this);

/**  In Shop class  */
RoomButton roomButton = new RoomButton(dock);&lt;/pre&gt;&lt;/div&gt;</description>
      <author>danpost</author>
      <pubDate>Thu, 04 Jun 2026 17:42:54 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151016#post_151016</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;danpost wrote...&lt;/div&gt;
On the other hand, if a field reference is kept:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public Player player;

public Dock() {
    super(600, 400, 1);
    player = new Player();  // retains reference
    addObject(player, 300, 200); // wherever
    // etc.&lt;/pre&gt;&lt;/div&gt;then, the reference is readily available to any actor in the world and any other object that gains a reference to this world.
&lt;/div&gt;Ok. I&amp;amp;#39;ve tried this, and it compiles fine, but gives an error that &amp;amp;quot;world cannot be null&amp;amp;quot; when tested
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public class RoomButton extends Buttons
{
    public Room room; //i know you didnt say to add this, but it was the only way that it would stop saying &amp;amp;quot;room&amp;amp;quot; is an undeclared variable
    /**
     * Act - do whatever the RoomButton wants to do. This method is called whenever
     * the &amp;amp;#39;Act&amp;amp;#39; or &amp;amp;#39;Run&amp;amp;#39; button gets pressed in the environment.
     */
    public void act()
    {
        change();
    }
    public void change()
    {
        if(Greenfoot.mouseClicked(this))
        {
            Greenfoot.setWorld(room);
        }
    }
    public RoomButton()
    {
        
    }
}&lt;/pre&gt;&lt;/div&gt;
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public class Dock extends World
{
    

    public int timer=0;
    
  
    public boolean baitNo=true; 
    public boolean rodNo=true;
    
    public boolean baitLow=false;
    public boolean rodLow=false;
    
    public boolean baitMed=false;
    public boolean rodMed=false;
    public boolean baitHigh=false;
    public boolean rodHigh=false;

    public Shop shop;
    public Room room;
    /**
     * Constructor for objects of class Dock.
     * 
     */
    public Dock()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600,400,1);
        setBackground(new GreenfootImage(&amp;amp;quot;dockbg.png&amp;amp;quot;));
        prepare();
        shop = new Shop();
        room = new Room();
        RoomButton roomButton = new RoomButton();
        addObject(roomButton,34,305);
        
        Greenfoot.start();
    }&lt;/pre&gt;&lt;/div&gt;</description>
      <author>bonyay</author>
      <pubDate>Thu, 04 Jun 2026 17:25:23 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151015#post_151015</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;danpost wrote...&lt;/div&gt;
I do not think that should be an issue.  Sounds like you are in a beginning programming class where they cannot expect you to do too much.  Maybe throwing in a few comments to indicate your intentions to build on it wouldn&amp;amp;#39;t hurt.&lt;/div&gt;I just was considering it because the main requirement is that everything in it actually works, so if I had features that didn&amp;amp;#39;t work, well, I&amp;amp;#39;d lose points. You&amp;amp;#39;re right though, it&amp;amp;#39;s a beginner course. However, it appears I am more of a beginner than the beginner course anticipated...</description>
      <author>bonyay</author>
      <pubDate>Thu, 04 Jun 2026 17:15:39 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151014#post_151014</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;danpost wrote...&lt;/div&gt;
On the other hand, if a field reference is kept:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public Player player;

public Dock() {
    super(600, 400, 1);
    player = new Player();  // retains reference
    addObject(player, 300, 200); // wherever
    // etc.&lt;/pre&gt;&lt;/div&gt;then, the reference is readily available to any actor in the world and any other object that gains a reference to this world.
&lt;/div&gt;If I used this, then do you think I should then have the code for changing worlds in the world and not the actor? Just asking before I actually try it
Edit: Wait, this made sense when I made the reply but now I&amp;amp;#39;m thinking about it more and I no longer make sense. Sorry, perhaps I should think it over further</description>
      <author>bonyay</author>
      <pubDate>Thu, 04 Jun 2026 17:03:02 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151013#post_151013</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;bonyay wrote...&lt;/div&gt;As a genuine piece of advice, do you think that I should gut it out of everything to do with shop and upgrades, and just make the goal to raise x amount of money by selling cans? This would just be to have something technically completed and submittable because it&amp;amp;#39;s due in literally 5 hours and I have other classes before then.&lt;/div&gt;I do not think that should be an issue.  Sounds like you are in a beginning programming class where they cannot expect you to do too much.  Maybe throwing in a few comments to indicate your intentions to build on it wouldn&amp;amp;#39;t hurt.</description>
      <author>danpost</author>
      <pubDate>Thu, 04 Jun 2026 16:55:48 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151012#post_151012</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;danpost wrote...&lt;/div&gt;You still have two &lt;span class="bb_italic"&gt;static &lt;/span&gt;variables in your &lt;span class="bb_italic"&gt;Dock &lt;/span&gt;class.  I am thinking that maybe &lt;span class="bb_italic"&gt;energyVar &lt;/span&gt;is a state of the &lt;span class="bb_italic"&gt;Player&lt;/span&gt; object and should probably be in the &lt;span class="bb_italic"&gt;Player &lt;/span&gt;class.  The other variable, &lt;span class="bb_italic"&gt;moneyVar&lt;/span&gt;, seems to be a &lt;span class="bb_italic"&gt;Player &lt;/span&gt;state as well and should probably be moved, as well (although, it might be more questionable).&lt;/div&gt;
I mean, everything to do with that has been fine, I think. I&amp;amp;#39;ll move them once I can delete the codes I mentioned in my previous reply! :)

Alright, I haven&amp;amp;#39;t gotten to moving them yet because my attempt at using your reference is now throwing some errors at my previous code. I think I know how to fix them using the knowledge you gave me, but it&amp;amp;#39;s rather laggy and I can hardly even start to try.

Third edit: I have now moved the code, but cant test it until i fix all errors lol

FOURTH edit: ok actually i lied i just compiled it and all the methods that use or affect energy and money work fine in the Player class!</description>
      <author>bonyay</author>
      <pubDate>Thu, 04 Jun 2026 15:14:31 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151011#post_151011</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;danpost wrote...&lt;/div&gt;With the following, no reference is kept:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;addObject(new Player(), 100, 365);&lt;/pre&gt;&lt;/div&gt;which is &lt;span class="bb_underline"&gt;almost &lt;/span&gt;equivalent to, or short for:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;Player player = new Player();
addObject(player, 100, 365);&lt;/pre&gt;&lt;/div&gt;The only difference between these two is that you can do something to &lt;span class="bb_italic"&gt;player&lt;/span&gt; somewhere later within the method currently being executed with the two-liner (since there is a local reference to the player in that method).  In the first case, you would have to go through all actors in the world and find the instance that is a &lt;span class="bb_italic"&gt;Player&lt;/span&gt; object to get the reference.

On the other hand, if a field reference is kept:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public Player player;

public Dock() {
    super(600, 400, 1);
    player = new Player();  // retains reference
    addObject(player, 300, 200); // wherever
    // etc.&lt;/pre&gt;&lt;/div&gt;then, the reference is readily available to any actor in the world and any other object that gains a reference to this world.

With the following, all worlds will be accessible provided the current world (or an actor within it) maintains a reference to the &lt;span class="bb_italic"&gt;Dock &lt;/span&gt;world:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public Shop shop;
public Room room;

public Dock() {
    super(600, 400, 1);
    shop = new Shop();
    room = new Room();
    prepare();
}&lt;/pre&gt;&lt;/div&gt;The codes of &amp;amp;quot;new Shop()&amp;amp;quot; and &amp;amp;quot;new Room()&amp;amp;quot; should not be used anywhere else in your project.  Nor should &amp;amp;quot;shop =&amp;amp;quot; and &amp;amp;quot;room =&amp;amp;quot; be found anywhere else.&lt;/div&gt;
This is all very helpful and digestible, thank you. I did this and compiled, then realized I had some &amp;amp;quot;new Room()&amp;amp;quot; and &amp;amp;quot;new Shop()&amp;amp;quot; code in the buttons, so right now im fighting a whole lot of lag to get through and delete it.

 As a genuine piece of advice, do you think that I should gut it out of everything to do with shop and upgrades, and just make the goal to raise x amount of money by selling cans? This would just be to have something technically completed and submittable because it&amp;amp;#39;s due in literally 5 hours and I have other classes before then. I genuinely want to make this game work, and would continue on the more complicated version once the school year ends (a couple days away!!).</description>
      <author>bonyay</author>
      <pubDate>Thu, 04 Jun 2026 15:11:28 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151010#post_151010</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>You still have two &lt;span class="bb_italic"&gt;static &lt;/span&gt;variables in your &lt;span class="bb_italic"&gt;Dock &lt;/span&gt;class.  I am thinking that maybe &lt;span class="bb_italic"&gt;energyVar &lt;/span&gt;is a state of the &lt;span class="bb_italic"&gt;Player&lt;/span&gt; object and should probably be in the &lt;span class="bb_italic"&gt;Player &lt;/span&gt;class.  The other variable, &lt;span class="bb_italic"&gt;moneyVar&lt;/span&gt;, seems to be a &lt;span class="bb_italic"&gt;Player &lt;/span&gt;state as well and should probably be moved, as well (although, it might be more questionable).</description>
      <author>danpost</author>
      <pubDate>Thu, 04 Jun 2026 14:58:46 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151009#post_151009</link>
    </item>
    <item>
      <title>Reply to How do i make a Project to .jar</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;Zildrion wrote...&lt;/div&gt;Why did the feature get removed and how do i do it now? :(&lt;/div&gt;Maybe download an older version of &lt;span class="bb_underline"&gt;Greenfoot &lt;/span&gt;to create the jar with.</description>
      <author>danpost</author>
      <pubDate>Thu, 04 Jun 2026 12:38:50 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66669?pid=151008#post_151008</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>With the following, no reference is kept:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;addObject(new Player(), 100, 365);&lt;/pre&gt;&lt;/div&gt;which is &lt;span class="bb_underline"&gt;almost &lt;/span&gt;equivalent to, or short for:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;Player player = new Player();
addObject(player, 100, 365);&lt;/pre&gt;&lt;/div&gt;The only difference between these two is that you can do something to &lt;span class="bb_italic"&gt;player&lt;/span&gt; somewhere later within the method currently being executed with the two-liner (since there is a local reference to the player in that method).  In the first case, you would have to go through all actors in the world and find the instance that is a &lt;span class="bb_italic"&gt;Player&lt;/span&gt; object to get the reference.

On the other hand, if a field reference is kept:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public Player player;

public Dock() {
    super(600, 400, 1);
    player = new Player();  // retains reference
    addObject(player, 300, 200); // wherever
    // etc.&lt;/pre&gt;&lt;/div&gt;then, the reference is readily available to any actor in the world and any other object that gains a reference to this world.

With the following, all worlds will be accessible provided the current world (or an actor within it) maintains a reference to the &lt;span class="bb_italic"&gt;Dock &lt;/span&gt;world:
&lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;public Shop shop;
public Room room;

public Dock() {
    super(600, 400, 1);
    shop = new Shop();
    room = new Room();
    prepare();
}&lt;/pre&gt;&lt;/div&gt;The codes of &amp;amp;quot;new Shop()&amp;amp;quot; and &amp;amp;quot;new Room()&amp;amp;quot; should not be used anywhere else in your project.  Nor should &amp;amp;quot;shop =&amp;amp;quot; and &amp;amp;quot;room =&amp;amp;quot; be found anywhere else.</description>
      <author>danpost</author>
      <pubDate>Thu, 04 Jun 2026 10:49:16 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151007#post_151007</link>
    </item>
    <item>
      <title>Reply to boolean not changing</title>
      <description>&lt;div class="bb_quote"&gt;&lt;div class="bb_quote_header"&gt;danpost wrote...&lt;/div&gt;
In &lt;span class="bb_italic"&gt;&lt;span class="bb_italic"&gt;Dock&lt;/span&gt;&lt;/span&gt; class, add reference for &lt;span class="bb_italic"&gt;Shop &lt;/span&gt;and &lt;span class="bb_italic"&gt;Room &lt;/span&gt;objects and, in &lt;span class="bb_italic"&gt;Dock &lt;/span&gt;constructor, assign objects to them.

If &lt;span class="bb_italic"&gt;Dock &lt;/span&gt;object reference is passed among the different world, all worlds would be accessible via that &lt;span class="bb_italic"&gt;Dock&lt;/span&gt; object.
&lt;/div&gt;
Alright, I&amp;amp;#39;ve done the other parts, and I&amp;amp;#39;m onto this. Maybe a stupid question, but are you saying like I should do &lt;div class="bb_code_wrap"&gt;&lt;pre class="brush: java"&gt;ShopButton shopbutton = new ShopButton();&lt;/pre&gt;&lt;/div&gt;? I am so sorry if this is aggravating, once again I am very new with rather limited guidance. I do best with specific examples, especially since I&amp;amp;#39;m new to this terminology. (my brain is also a little fried from it being 1 AM with no sleep in 2 days combined with a lovely sprinkle of stress)</description>
      <author>bonyay</author>
      <pubDate>Thu, 04 Jun 2026 05:40:22 +0000</pubDate>
      <link>https://www.greenfoot.org/topics/66668?pid=151006#post_151006</link>
    </item>
  </channel>
</rss>
