Scenario - There is one gumball machine and 3 type of coins (quarter , fake quarter and dime) .
Objective - When i bring the coin on the gumball machine it should disappear
Problem - Coin is not disappearing , confused about how to match (x,y ) coordinate of gumball machine and coin.
i tried writing a code for gumball machine for quarter let me know whats the mistake i am doing and why coin is not disappearing. Also there is no gridlines in this scenario as compared to examples such as wombat and other scenarious mentioned in greenfoot.
public void act()
{
if(foundQuarter()) {
removeQuarter();
}
}
public void removeQuarter()
{
Actor quarter = getOneObjectAtOffset(0, 0, Quarter.class);
// eat the leaf...
getWorld().removeObject(quarter);
}
public boolean foundQuarter()
{
Actor quarter = getOneObjectAtOffset(0, 0, Quarter.class);
if(quarter != null) {
return true;
}
else {
return false;
}
}
}