I have a class named Label:
a class called vse:
and a class called gumb1:
The problem is, that displayed points are always: Tocke: 0. In the object gumb1 points are increasing, but when i call them for display, not working. Any ideas?
public class Label extends vse { private String text; public void act() { Integer i = new Integer(Points); text = "Tocke: " + i.toString(); int stringLength = (text.length() + 2) * 10; setImage(new GreenfootImage(stringLength, 16)); GreenfootImage image = getImage(); updateImage(); } public void PointsLabel(int Points) { Integer i = new Integer(Points); text = "Money: " + i.toString(); int stringLength = (text.length() + 2) * 10; setImage(new GreenfootImage(stringLength, 16)); updateImage(); } public void updateImage() { GreenfootImage image = getImage(); image.clear(); image.setFont(new Font("Tahoma", Font.BOLD, 12)); image.setColor(Color.WHITE); image.drawString(text, 1, 12); } }
public class vse extends Actor { public int Points; public int pristej() { Points++; return Points; }
public class gumb1 extends vse { /*public int Points; public gumb1 () { Points = 0; }*/ public void act() { onClick(); } public void onClick() { if(Greenfoot.isKeyDown("A")) { Actor gumbek = getOneObjectAtOffset (0, 0, pikca.class); if(gumbek != null) { World world; world = getWorld(); world.removeObject(gumbek); Greenfoot.playSound("Đđđ.wav"); pristej(); } } } /* public int getPoints() { return Points; }*/ }