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

2017/10/16

How to make a character collectible and add to the score

NiahCO NiahCO

2017/10/16

#
 public void act() 
    {
        setLocation( getX() - starspeed, getY() );

    if (getIntersectingObjects(Dafad.class)!=null) {
            JumpySheep Shortcut = (JumpySheep) getWorld();
            Shortcut.sgor.setValue(Shortcut.sgor.getValue()+2);
    }
}
public void act2()
{
    if (getIntersectingObjects(Dafad.class)!=null) {
            JumpySheep Shortcut = (JumpySheep) getWorld();
            Shortcut.removeObject(this);
    } 
}
I'm trying to make the star collectible but every time I put the two parts of code into the same public void the star doesn't spawn. Can somebody please help?!! Sorry that some things are in Welsh.
danpost danpost

2017/10/16

#
You should be able to place line 14 immediately after line 7 and remove the act2 method.
You need to login to post a reply.