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

2014/9/24

The Score isn't Updating

Vlad32142 Vlad32142

2014/9/24

#
public void act() { MoveUD(); } int Speed=2; public void MoveUD() { if(canSee(pow.class)) { eat(pow.class); Speed++; pow newpow; newpow = new pow(); World world; world = getWorld(); world.addObject(newpow,getWorld().getWidth()-50,Greenfoot.getRandomNumber(400)+200); } if (Greenfoot.mouseMoved(null)) { MouseInfo mouse = Greenfoot.getMouseInfo(); setLocation(getX(), mouse.getY()); } } public boolean canSee(Class clss) { Actor actor = getOneObjectAtOffset(0, 0, clss); return actor != null; } public void eat(Class clss) { Actor actor = getOneObjectAtOffset(0, 0, clss); if(actor != null) { getWorld().removeObject(actor); } } The "Speed" Score Int Updated Here public void act() { setLocation(getX()-4,getY()); if(atWorldEdge()) { Greenfoot.stop(); setImage("button-red.png"); } } public boolean atWorldEdge() { if(getX() < 10 || getX() > getWorld().getWidth() - 10) return true; if(getY() < 10 || getY() > getWorld().getHeight() - 10) return true; else return false; }
Vlad32142 Vlad32142

2014/9/24

#
The "Speed" Score Isn't Updated Here
Super_Hippo Super_Hippo

2014/9/24

#
Where is the problem? I don't see any code related to a score. (Please use the 'code' tags to post code.)
danpost danpost

2014/9/24

#
How do you know the 'Speed' value is not updating? I bet if you 'eat' a few 'pow' objects, then stop the scenario, right-click on the object that eats 'pow' objects and 'Inspect' it, the value of Speed' will have increased from 2.
Super_Hippo Super_Hippo

2014/9/24

#
Ah, now I know what he meant with his second post...
You need to login to post a reply.