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

2018/2/10

I can't figure out why this won't come up

Xolkiyr Xolkiyr

2018/2/10

#
I've been searching all over the place for an answer, thought I'd come back to the source. The following code is supposed to wait for the mouse to hover over an ore deposit, then display a label that shows the amount of ore there. But for the life of me, nothing is changing. No errors either so to the best of my knowledge the code should work.
    /**
     * Tell us how much ore is left in this vein.
     */
    private void Act(){
        if (Greenfoot.mouseMoved(this) && info == null)
        {
            info = new Label(ore, 12);
            MouseInfo mouse = Greenfoot.getMouseInfo();
            getWorld().addObject(info, mouse.getX(), mouse.getY());
        }
        else if (Greenfoot.mouseMoved(null) && !Greenfoot.mouseMoved(this))
        {
            getWorld().removeObject(info);
            info = null;
        }
    }
Any ideas?
Vercility Vercility

2018/2/10

#
Why the hell is your act private and capitalized?
Xolkiyr Xolkiyr

2018/2/10

#
And that would probably be why... all it takes is one symbol out of place, let alone a whole word, to mess up code.
Xolkiyr Xolkiyr

2018/2/10

#
Nope, still not doing what's intended.
Xolkiyr Xolkiyr

2018/2/10

#
Didn't even see your comment about Act being capitalized. Fixing that fixed the issue. Thank you.
You need to login to post a reply.