Change Image with Change Attribute?

perfectanswerperfectanswer PRO Posts: 121
edited January 2012 in Working with GS (Mac)
Hello,

to save a big amount of rules, my idea is to change my images not with the ChangeImage behavior, but instead of this I will use the Change Attribute behavior like this:

Change Attribute:>self.image = MyImageName_1.png
But...
How I can change the number?
The number ad the end of the image name is a attribute (GUINumber(int))
So the Name looks like MyImageName_GuiNumber.png I see the before a while ago here in the forum or on youtube, but I can't find anymore. Anyone know the syntax for this?? Thanks in advance Bernd

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    Hi Bernd

    The syntax for this would be:

    self.image = MyImageName_..GUINumber(int)..".png"

    The double dot is really useful for concatanating attributes with text, etc.

    Maybe just in case of a problem, don't use the underscore (_), so it'd be a bit cleaner:

    self.image = MyImageName..GUINumber(int)..".png"

    ----------------------------------------------
    http://davidgriffinapps.co.uk/

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • perfectanswerperfectanswer PRO Posts: 121
    Hi Gyroscope,

    many thanks for helping me out.
    Works great, the underscore don't stop the show. If I ran in trouble with this I can rename the files and change the filenames in the xml, but.. just for the case.
    Anyway, THIS is a great way to shrink the rules to a minimum.
    Thanks again Giro!
    Bernd
  • GhostShipAppsGhostShipApps Member Posts: 81
    I just saw this post and I think it would help me with my game, but I don't get it.
    I have 20 images, named 00.PNG to 20.PNG.
    If I want to change the actor's image to the next number, what should I do with my rule?
    What I don't understand is when you said: "The number ad the end of the image name is a attribute (GUINumber(int))"
    What is a GUINumber?
    When I try to go to the next image I'm getting only a white square. If I could understand the the GUINumber thing I think I can get it. Currenty I am doing it with change image behiavior. Thanks!
  • GhostShipAppsGhostShipApps Member Posts: 81
    I am bumping this, just looking for more information on how to change the self image attribute. I know it's explained in this post but I can't manage to make it work. Any help is welcomed.
    Thanks.
  • MotherHooseMotherHoose Member Posts: 2,456
    edited January 2012
    easiest way: name images 0 through 8 or whatever (No text…only numbers)

    then changeAttribute: self.image TO: self.Image+1

    for several imageAnimations: make names of the image of the sequence in double digits: … 10 through 19; 20-29; etc.

    @};- MH
  • GhostShipAppsGhostShipApps Member Posts: 81
    Thanks so much MotherHoose, from now I will start any image sequence with the number 10.
    It's working and I saved 19 rules.
  • MotherHooseMotherHoose Member Posts: 2,456
    glad @GhostShipApps you got the progression!

    why are you saving those 19 rules? toss them out! 8-|

    forgot to tell you to have the image changes enclosed in a
    Rule: when (All)
    Attribute: self.Image ≥ 0
    Attribute: self.Image ≤ 9
    --then do the changeAttributes

    don't want the computer to keep on adding and then display a 20.png image.

    @};- MH
  • GhostShipAppsGhostShipApps Member Posts: 81
    Previously, for every new image I needed I had a change image rule into the actor. I couldn't use animation because the image displayed depends on the position of the actor. Now I just change the self image.
    thanks again
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    would be great if there was a template for this! I'm having issues with it.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Heh figured this out and used timers with it control the animation. I think I just misinterpreted some of the things u said. Thanks!
Sign In or Register to comment.