Change an object randomly

seymourseymour Member Posts: 56
edited November -1 in Working with GS (Mac)
is there a way to have one actor and have it change to a many different images randomly each time you touch it

Comments

  • msonesmsones Inactive, Chef Emeritus Posts: 75
    The easy, if laborious method:

    Rule: on touch, change attribute [changeimage] to random(1,10)
    Rule: if [changeimage]=1, change image to 1.jpg.
    Rule: if [changeimage]=2, change image to 2.jpg.

    And so forth - I think you probably get the idea. There may be an easier way, but this at least should work.
  • Rob2Rob2 Member Posts: 2,402
    or you can use a change attribute behaviour to change the self.image attribute to

    "imagefilename_"..random(1,10)..".png"
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Rob2 said:
    or you can use a change attribute behaviour to change the self.image attribute to

    "imagefilename_"..random(1,10)..".png"

    was just about to say that, keeps it all it one rule for each image. Just make sure you have all your images numbered
  • seymourseymour Member Posts: 56
    Thanks every one I got it working.
Sign In or Register to comment.