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

2019/6/4

Get clicked image name

ChaosPhantom ChaosPhantom

2019/6/4

#
Is there a way to get the image name of a clicked actor?
Super_Hippo Super_Hippo

2019/6/4

#
The path of the image isn't saved when creating the image. So you have to save the filename separately and get this String when clicking on the actor.
ChaosPhantom ChaosPhantom

2019/6/4

#
Yea i was talking about something like "Block.png" because I want to create an if statement with "if (this list contains the string of the actor that was clicked "Block.png")"
Super_Hippo Super_Hippo

2019/6/5

#
1
2
3
4
5
6
7
8
9
10
11
12
13
private String imgName = null;
 
public ClassName(String imgFile)
{
    imgName = imgFile;
    setImage(imgName);
}
 
//(if needed)
public String getImageName()
{
    return imageName;
}
Then you have several options. You can check for a click here in this class. Then either send it to somewhere else to check with the list or check it from here. Or you check for the click on this object from somewhere else.
You need to login to post a reply.