Hello everyone,
I have to create a small program in greenfoot so childeren can learn to match text with an image.
To text is draggable to an image. This code check if text is dragged to an image and when the mouse is released, it returns true.
Now I need to now what text is dropped on an image
I also need to now the text of the Woord.class.
So I want to know the name of the actor a text is released on.
I tried
but I got java.lang.Object cannot be converted to Woord.
Can anyone help me getting the name (naam)?
public boolean isWoordGesleept()
{
if (Greenfoot.mouseDragEnded(this) == true &&this.isTouching(Woord.class))
{
return true;
}
return false;
}
public String getWoord()
{
return text;
}
import greenfoot.*;
public class Woord extends Actor
{
private String naam;
private String afbeelding;
//private int foutGeraden;
//private boolean geraden;
public Woord(String naam, String afbeelding)
{
this.naam = naam;
this.afbeelding = afbeelding;
this.setImage(afbeelding);
this.getImage().scale(100,100);
}
public String getNaam()
{
return naam;
}
public void act()
{
this.hover();
}
public void hover()
{
if (Greenfoot.mouseDragEnded(this) == false && this.isTouching(SleepbaarTekstvak.class))
{
this.getImage().scale(150,150);
}
else
{
this.getImage().scale(100,100);
}
}
}
Woord woord = getoneobjectatoffset(0,0,Woord.class)
