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

2014/6/12

Set image depending on variable in another class

Crystic Crystic

2014/6/12

#
Hi all, I wonder if anyone could help me. What I am trying to make happen is an actor appear when a character object collides with another object. I have that part worked out, but now I need to take it to the next step and make the actor that appears image change depending on a variable. The code I have is pasted here: GameWorld: http://pastebin.com/VD4sE1y0 obj_letterBox: http://pastebin.com/K03DGhSd There is also a third actor that is a dummy actor that will be created and have the image set to whatever the variable "thisLetter" is in the GameWorld file. If someone could lend a hand here, it would really help a lot! Thanks.
CooliMC CooliMC

2014/6/12

#
Can pls post the whole code here ?
CooliMC CooliMC

2014/6/12

#
write a String image = {pic1,pic2....} , twoints : int imagenumber and imagenumberold , an if(Imagenumber!=imagenumberold){image in the act() methode . I hope i could help you , otherwise i hope others can help you
danpost danpost

2014/6/12

#
Have the dummy actor set (or finalize) its image in an 'addedToWorld' method. Please refer to the Actor class API documentation for information on this method.
You need to login to post a reply.