How to change image (out of a pool of 100 images) without 100 rules????

bluelotusbluelotus Member Posts: 96
edited November -1 in Working with GS (Mac)
Hi all,

Having a hard time figuring this out....

I have one image on the screen. I have a pool of 100 images. The image on the screen needs to change every couple seconds.

Now the way I have been doing it is every couple of seconds I choose a random number and there are 100 change image rules that correspond to the random numbers. The problem is,
a.) when I open that actor that contains all the change image rules I have to wait forever for all the rules to load (the rule windows are all open and then collapse one at a time). Sometimes take 3 minutes each time. And when you are trouble shooting (preview>open the actor, preview>open the actor) it takes way too long.
b.) I want to add more images to the pool but I dont want to have 300-400 rules inside an actor.

Is there any way to use ONE variable to change the image? Or any other ideas would be greatly appreciated :)

THANKS!!!

Comments

  • jstrahanjstrahan Member Posts: 498
    use 99 rules and 1 otherwise
  • Rob2Rob2 Member Posts: 2,402
    if your images were named 1 to 100.png you could use
    self.image = random(1,100)..".png"
  • Rob2Rob2 Member Posts: 2,402
    this isn't going to check for duplicate randoms...but you get the idea
  • jstrahanjstrahan Member Posts: 498
    didnt know .. worked outside of text good tip if it works and can always set up rules to check for duplicates
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Like Rob2 says:

    Timer Every 3 seconds
    -----Change Attribute: self.Image To: "image"..random(1,100)..".png"

    You will need to name your images like this: image1.png, image2.png, image3.png, etc.
  • bluelotusbluelotus Member Posts: 96
    that works great! I had tried something similar to that before but I didn't know I needed ".."

    perfect!

    @Rob2 (or whoever)... Is there a simple way to check for duplicates without having to make a whole bunch of attributes?
  • bluelotusbluelotus Member Posts: 96
    one more question.... how would I make the images progress by 1 instead of random?
  • JackBQuickJackBQuick Member Posts: 524
    This demo by tshirtbooth might be helpful:

    HOW TO display random images with out repeats
  • bluelotusbluelotus Member Posts: 96
    @jack, thanks... I have seen that one, but again, he is writing out every possibility, which is ok for 5 cards but way more complex for 100+ images.

    I think I can just make a pseudo-random sequence by cycling through the images by odd numbers. Just add 7,9,11 to the the image number and when it is greater than 100 just minus 100. This would make it so they dont repeat but aren't in order.

    The question of the syntax still remains. How do I write that math in the expression editor?
    -----Change Attribute: self.Image To: "image"..random(1,100)..".png" <------this is with a random number. how do I make it +7?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You need to make an integer attribute in the Actor, called something like 'currentImage'. Initially set it to 1 or whatever the first image is.

    Timer Every 3 seconds
    -----Change Attribute: self.currentImage To: self.currentImage + 1
    -----Change Attribute: self.Image To: "image"..self.currentImage..".png"
  • bluelotusbluelotus Member Posts: 96
    brilliant. you rock!
Sign In or Register to comment.