Actor with Random Image
rdvd83
Member Posts: 11
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
In your image names, remove the "image" bit. It should only be "1.png", "2.png" etc.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
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.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
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.."•"
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks for the help!
I tried both ways and they do not work. It just displays the actual text, not the equation. What am I doing wrong??
Did you click the 'e' to open the expression editor and then type it in?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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?
Search the forums for custom timer
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx