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

2018/6/14

Is it possible to get the image set by the UI

MrBradley MrBradley

2018/6/14

#
I have a case where a base class forces an image to be set in the code. I was wondering if it is possible to get the image assigned by the user via the GF UI. What I am seeing is that this image is reset by the code in the base class, and I believe that setImage is called as a convenience, but is overridden by the baseclass code. I was hoping that GF has a way of retrieving filename of the image the user selected in the UI. Mr B.
danpost danpost

2018/6/18

#
MrBradley wrote...
I was hoping that GF has a way of retrieving filename of the image the user selected in the UI.
Unfortunately, GF does not currently provide a way to access the filename of an image selected for an Actor subclass in the UI. For clarification of your issue, please show an example of what code you are working with (all classes involved) and explain exactly what you are trying to do and why. That may open up possible solutions to the issue.
MrBradley MrBradley

2018/6/22

#
After a bit of investigation: you can get the name of the image file (3.1.0) from calling the toString() method.
danpost danpost

2018/6/22

#
MrBradley wrote...
After a bit of investigation: you can get the name of the image file (3.1.0) from calling the toString() method.
True. Note however: (1) you will have to get it before changing the image set to the actor; and (2) it is not the only thing in the String object returned (it contains not only the name, but the full url path of the file and where in memory the image is stored). If you want the name by itself, you will need to extract that portion of it it from the string.
You need to login to post a reply.