multiple images

crapscraps Member Posts: 353
I am able to use the touch rule and change image attribute to change to a new image. How can I do that multiple times?

Comments

  • chosenonestudioschosenonestudios Member Posts: 1,714
    what exactly do you mean by "multiple times"?
  • crapscraps Member Posts: 353
    I have a single image that if touched will change to another image - I would like to be able to touch it again and change to a another new image. I need to do that six times

    Thanks
  • chosenonestudioschosenonestudios Member Posts: 1,714
    do you want it to be random or preset?
  • crapscraps Member Posts: 353
    preset!

    I have two seperate images on the screen and if touched one image will change. But if I touch it again nothing will happen. If I follow with a second image change attribute both images change at the same time.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    k one sec
  • chosenonestudioschosenonestudios Member Posts: 1,714
    alright create a attribute called image changer (err whatever you want it to be called) set it @ 0
    then create a rule that says when attribute "image changer" = 0 rule when touched change image to blankedy blankedy, change attribute "image changer" to 1

    then create another rule that says when attribute "image changer" = 1 rule when touched change image to blankedy blankedy, change attribute "image changer" to 2

    you keep doing that over and over again until you get to 5 and then when that ones touched change attribute "image changer" back to 0 and that will loop it

    A side note, I'm sure there are other ways of doing it (probably more processor efficient), but this is what worked for me. Good luck! :)

    -Will
  • crapscraps Member Posts: 353
    Thanks will give it a try. Are there any books to learn more about gamesalad or are we on our own except for forum help?
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Oh and when your changing the attribute make sure you wrap that in a timer otherwise it will activate all the commands at once and it won't work. Like on mine it says: when touch is pressed change image, timer after .25s change attribute (you can use pretty much any value you want, it just affects how long it takes you to change images, its not important how long it is, just that its there.

    Yep no problem, there might be some books or tutorials to get you started (don't know of any, but google might be able to clear that up for you), but I found the best way to learn is just by digging in, making games, reading the support tab (alot of questions have been answered there) watching tutorials (there are quite a bit on youtube) and downloading other peoples templates, theres not really a right way to learn it, and yes for complicated things you just can't wrap your head around asking on the forums. Good luck!:)

    -Will
  • crapscraps Member Posts: 353
    create a attribute called image changer (err whatever you want it to be called) set it @ 0

    CREATE THIS AS AN ACTOR ATTRIBUTE?

    create a rule that says when attribute "image changer" = 0 rule when touched change image to blankedy blankedy, change attribute "image changer" to 1

    DO I CREATE A RULE FIRST THEN CHANGE ATTRIBUTE?

    Hope i am making some sense here - I am trying to figure this out. Thanks
  • chosenonestudioschosenonestudios Member Posts: 1,714
    "CREATE THIS AS AN ACTOR ATTRIBUTE?"

    no create it as a game attribute, under one of your scenes click on attributes, add new, integer

    "DO I CREATE A RULE FIRST THEN CHANGE ATTRIBUTE?"

    create a rule and change the attribute inside the rule (make sure you use the timer (previous post))

    Good Luck! :)

    -Will

    ___________________________________________________________
    (JetPacked!) http://itunes.apple.com/us/app/jetpacked/id361063574?mt=8
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Name your images like this: image1.png, image2.png, image3.png, etc...

    Then, in the Actor that needs to change its image, create an integer attribute named "currentImage" (without the quotes)

    Set this initially to 1.

    Then create a Rule in the Actor like this:

    Rule
    All
    When Touch is Pressed
    When self.currentImage < 6
    -----Change Attribute self.currentImage To: self.currentImage + 1
    -----Change Image To: "image"..self.currentImage..".png"

    Hope this helps!
    Joe
  • chosenonestudioschosenonestudios Member Posts: 1,714
    ugh this is probably a much better way than mine, Joe, but if it has to be less than 6 and it keeps adding 1 won't it eventually be above or equal to 6 thus making the equation false?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Yes, That's why I put that second condition in the Rule...
  • crapscraps Member Posts: 353
    I got this far:

    ule
    All
    When Touch is Pressed
    When self.currentImage < 6
    -----Change Attribute self.currentImage To: self.currentImage + 1

    FOR THIS: ---Change Image To: "image"..self.currentImage..".png"

    DO I USE CHANGE "IMAGE ATTRIBUTE" AND THEN PICK THE IMAGE2.PNG? OR SOMETHING ELSE?

    THATS WHAT I DID - IT WORKS AND SWITCHES TO THE NEXT IMAGE - BUT -
    I CAN NOT GET IT TO GO TO IMAGE 3.

    THANKS
  • crapscraps Member Posts: 353
    Is this how I set up the behaviors?

    Rule

    all - actor receives event -touch-pressed

    Rule

    all - attribute - self.currentimage<6

    Change attribute

    self.currentimage - to - currentimage+1

    Change image attribute - ?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Oops sorry, use Change Attribute, not Change Image.

    So actually:

    Rule
    All
    When Touch is Pressed
    When self.currentImage < 6
    -----Change Attribute: self.Image To: "image"..(self.currentImage + 1)..".png"
  • crapscraps Member Posts: 353
    Thanks - this helped.

    However - when preview everything and "touch" the image - it changes to "image missing"
    Can the next images just be under images? I have them there labeled image1.png etc.

    ---Change Attribute: self.Image To: "image"..(self.currentImage + 1)..".png"

    Under TO: do I just type in "self.currentimage + 1" ?

    Thanks -
  • crapscraps Member Posts: 353
    Thanks - this helped.

    However - when preview everything and "touch" the image - it changes to "image missing"
    Can the next images just be under images? I have them there labeled image1.png etc.

    ---Change Attribute: self.Image To: "image"..(self.currentImage + 1)..".png"

    Under TO: do I just type in "self.currentimage + 1" ?

    Thanks -
  • crapscraps Member Posts: 353
    WOW - Sorry about the double post - how do you edit a previous post?

    image"..(self.currentImage + 1)..".png"

    Do I do:

    --pull down menu -" image1.png" - next pull down menu - "currentimage" then type "+ 1" ?

    Crazy
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Make sure that you do not just type that into the expression editor...

    Any time you see a "game.[whatever]" or a "self.[whatever]", you need to select that from the drop-down list.

    Make your Rule look exactly as the one that I have above:

    Rule
    All
    When Touch is Pressed
    When self.currentImage < 6
    -----Change Attribute: self.Image To: "image"..(self.currentImage + 1)..".png"

    Make sure self.Image and self.currentImage are selected from the drop-down menu in the expression editor.
  • crapscraps Member Posts: 353
    Heres what I did -

    http://tinypic.com/r/104kpbm/5

    still comes up "missing image"
    I have the next image in my image folder and have made the next image an actor.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    The expression in the expression editor needs to be this exactly:

    "image"..(self.currentImage + 1)..".png"

    quotes and everything. self.currentImage needs be chosen from the drop-down menu
  • crapscraps Member Posts: 353
    Your responses have been very helpful - but WOW - I can not get this to work. I copied your expression perfect and yes I used the drop down menu when needed.

    Still no image change - I am sure something small is missing. Is this this only way to do this?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Oops. Sorry about that...
    I was just typing off the top of my head.

    This is correct, follow this exactly:

    Name your images like this: image1.png, image2.png, image3.png, etc...

    Then, in the Actor that needs to change its image, create an integer attribute named "currentImage" (without the quotes)

    Set this initially to 1.

    Then create a Rule in the Actor like this:

    Rule
    All
    When Touch is Pressed
    When self.currentImage < 6
    -----Change Attribute self.currentImage To: self.currentImage + 1
    -----Change Attribute self.Image To: "image"..self.currentImage..".png"

    Hope this helps!
    Joe
Sign In or Register to comment.