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

2013/5/2

How do I make the world count my score?

Yasmine Yasmine

2013/5/2

#
So I've this game with 3 different bonus, which one has his Points. So far I can make the score apper at the top of my game but when the actor intersect with the Object he doesn't count the points.... public class Rolo extends Actor { private GreenfootImage image1; private GreenfootImage image2; private boolean molhado = false; private int velocidade; private int contadorCharco; private boolean spaceKeyDown = false; private int xPos = 20; private int yPos = 117; private boolean podeSaltar = true; private int yRestringeDistSalto; private GreenfootSound saltoSound = new GreenfootSound("salto.WAV"); private int pontos; public Rolo () { image1 = new GreenfootImage ("rolo.png"); image2 = new GreenfootImage ("roloTriste.png"); pontos=0; } public void touchBonus(){ Bonus bonusganho = (Bonus)getOneIntersectingObject(Bonus.class); if(bonusganho !=null){ pontos=pontos + bonusganho.getPontuacao(); getWorld().removeObject(bonusganho); } } public void touchStar() { Actor touchStar = getOneIntersectingObject(Star.class); if(touchStar !=null) { getWorld().removeObjects(getWorld().getObjects(Star.class)); } }
danpost danpost

2013/5/3

#
You are changing the value of 'pontos' when intersecting the 'bonusganho'; but you are not adjusting the image of the object that you want to use to display that value (hoping and praying it is an object).
You need to login to post a reply.