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

2013/2/9

Image changing

Gingervitis Gingervitis

2013/2/9

#
Is it possible to change the image of a class from another class?
danpost danpost

2013/2/9

#
Of course it is. You just need a reference to the object of that class whose image you want to change. For example, if an ActorA object intersects an ActorB object and you want to change the image of the ActorB object from the ActorA class:
Actor actor = getOneIntersectingObject(ActorB.class);
if (actor != null) actor.setImage(new GreenfootImage("newImage.png");
You need to login to post a reply.