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

Report as inappropriate.

trollathon
trollathon presents ...

2010/3/27

please help

i cant seem to make it so that the fruit
disappears when the fly touches it. could someone please tell me how in the comments?
i also need to know how to make the fruit switch to a random costume each tim

3145 views / 21 in the last 7 days

Tags: with-source

open in greenfoot
Your browser is ignoring the <APPLET> tag.
bournebourne

2010/3/27

In your touchingfuit method in the fly class, before returning, if actor is not null, then do getWorld().removeObject(touching) or if you want to make it move to a different location do touching.setLocation(Greenfoot.getRandomNumber(getWorld().getWidth()), Greenfoot.getRandomNumber(getWorld().getHeight())). to change its picture do: touching.setImage(new GreenfootImage("picture file")).
bournebourne

2010/3/27

public boolean touchingfuit() { Actor touching = getOneObjectAtOffset ( 0, 0, fruit.class); if (touching != null) { getWorld().removeObject((fruit)touching); return true; } return false; }
trollathontrollathon

2010/3/27

ok.... i *sorta* get it... thx for the help

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.