So what I am trying to do is when my sprite it touching the coin (emerald) the coin should be removed and then score should be incremented by one but it is not working and I am running into errors. Here are the classes that are necessary
I would appreciate the help!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class score here. * * @author (your name) * @version (a version number or a date) */ public class score extends OTHER { int score = 0; public void updateImage() { setImage(new GreenfootImage("Score: " + score, 20, Color.WHITE, Color.BLACK)); } public score() { updateImage(); } public void addScore() { score++; updateImage(); } }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class coins here. * * @author (your name) * @version (a version number or a date) */ public class coins extends OBJECTS { private score score; public void act() { scrollingMethods(); checkCoins(); } public void checkCoins() { Actor sprite = getOneObjectAtOffset(0,0,sprite.class); if (sprite != null) { score++; getWorld().removeObject(this); } } }