Actor with Random Image

How can I create an actor with random images?
I have tried to change attribute on a timer - self.image to "image"..random(1,4)..".png"
I added for images into gamesalad with name image1.png through image4.png
When I run the preview it starts on the image I gave the actor but then changes to nothing (white square).

What else do I need to do?

Thanks.

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    In your image names, remove the "image" bit. It should only be "1.png", "2.png" etc.

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    Oh, and you don't need that ".png" at the end. As long as your expression is set up correctly, it should just grab the image without that extension.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    If your images are named image1.png, image2.png, etc. then you are correct in your expression but you don't need the .png as @Braydon_SFX‌ said:

    "image"..random(1,4)

    Or you can rename them, as he suggested.

    To troubleshoot, add a DisplayText with self.Image and see what it's displaying as the image name. I like to add symbols before and after so I can verify it's in fact blank, so this is what I put in the DisplayText expression:

    "•"..self.Image.."•"

  • rdvd83rdvd83 Member Posts: 11

    Thanks for the help!

  • rdvd83rdvd83 Member Posts: 11

    I tried both ways and they do not work. It just displays the actual text, not the equation. What am I doing wrong??

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Did you click the 'e' to open the expression editor and then type it in?

  • rdvd83rdvd83 Member Posts: 11

    It works now. I used a timer and change the image every dew seconds. I have another question. I want the to create a rule when touch is pressed to stop the timer and display current image. Any ideas?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Search the forums for custom timer

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    You may also be able to use a loop if you wanted the timer to run extremely quick. The Loop runs every cycle so it's very quick.

Sign In or Register to comment.