How do I change actors with each click or touch?

leahc117leahc117 Member, PRO Posts: 9

Hello,
I am new to gamesalad and have only done the basics so far. I would like an image (actor) in the center of the screen to change to another image each time it is touched or clicked. What is the best way to do this? I would like to pan though 10 images in each scene. Thank You!

Best Answers

  • SocksSocks London, UK.Posts: 12,822
    Accepted Answer

    @leahc117 said:
    would that have each image displayed then disappear and the next one displayed etc - so there is only 1 image showing with each click or touch?

    Yes, only 1 image showing.

    The image is replaced with each click, so if you start with image '0', and then you click image '0' will be replaced with image '1' . . . keep clicking to move through the images, at the end when you reach image 12 (or whatever your last image is) it will loop back around to the start.

  • SocksSocks London, UK.Posts: 12,822
    Accepted Answer

    @leahc117 said:
    I think i got it - i selected mod and self image from the lists instead of typing them in and it worked.

    Yeah ! Whoops, sorry I should have pointed that out, like you say you need to select self.image from the drop-down attribute menu.

    You can actually type 'mod' in if you like - or you can select it from the drop down function menu - whether you type it in by hand or select it from the menu makes no difference (unlike attributes).

Answers

  • SocksSocks London, UK.Member Posts: 12,822

    A quick and easy way would be to name your images sequentially, 0, 1, 2, 3, 4, 5, 6 . . etc

    Then apply the first image to the actor that will display them . . . and add this rule:

    When touch is pressed:
    --Change self.image to mod(self.Image +1,X)

    X is the amount of images you want to display - so if you have 12 images it would be mod(self.Image +1,12)

  • leahc117leahc117 Member, PRO Posts: 9

    would that have each image displayed then disappear and the next one displayed etc - so there is only 1 image showing with each click or touch?

  • leahc117leahc117 Member, PRO Posts: 9

    To clarify - I've created a rule - when mouse button is down - then selected
    change attribute self.Image to mod(self.Image+1, 11) - and I did this after selecting image 0. the images are all under the actors tab. It doesn't work right - the initial image is there and when i click on it the original image disappears and then nothing happens.
    Thanks!

  • SocksSocks London, UK.Member Posts: 12,822

    @leahc117 said:
    To clarify - I've created a rule - when mouse button is down - then selected

    I'm not sure what "mouse button is down - then selected" means, the 'then selected' part doesn't refer to a GameSalad function.

    @leahc117 said:
    change attribute self.Image to mod(self.Image+1, 11)

    Yes, that's right, this should cycle through 11 images, each click should move from one image to the next.

    @leahc117 said:
    and I did this after selecting image 0. the images are all under the actors tab. It doesn't work right - the initial image is there and when i click on it the original image disappears and then nothing happens.
    Thanks!

    Can you upload a screenshot of the rule you are using . . . .

  • leahc117leahc117 Member, PRO Posts: 9

  • leahc117leahc117 Member, PRO Posts: 9

  • leahc117leahc117 Member, PRO Posts: 9

    I think i got it - i selected mod and self image from the lists instead of typing them in and it worked.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Shouldn't that be '11' rather than '17'?

Sign In or Register to comment.