CHECK IT! Need help from the pros here on the forum!!

School on Interactive DesginSchool on Interactive Desgin Member Posts: 68
edited November -1 in Working with GS (Mac)
Ok GameSalad Pros I need some help please. Let me explain what I am trying to do.

- I have 100 images (a image sequence) I want to press a key to move between these images. For example I want to press the "A key" to move down one image in the sequence and press the "S key" to up one image in the sequence.

Here is how I set it up. I created an integer attribute and get it a default of 1.
I then set it up so when I press the "A key" I subtract 1 from the attribute I created and when I press the "S key" I add 1 to the attribute.

Then all I needed to do was do a "change image" behavior that is linked to the number that is currently set in the integer attribute. This all works great! But there is one problem. I have to create a change image rule for every single photo I want to move between.

SO HERE IS MY QUESTION...

Is there a way to write a single expression that will let me change the images?
Basically I need something like this:

Integer Attribute's number = image number

THANKS!!!!!!!!!!!!!!!

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    Yes, there's a way to do this (which I only discovered myself recently with FMG's help).

    Use a change attribute behaviour to change your actor's 'self' image.

    Here's a screenshot for the syntax related to it in the expression editor:

    https://files.me.com/qsheep/7imzn4

    Essentially what's happening here is I have six separate images. I call them stars0.png, stars1.png etc etc up to stars5.png

    The high score is a number between 0 and 5.

    What this does is negate the need to add five 'change image' behaviours, and just use one change attribute behaviour as you requested.

    I think that should work. Hope that helps!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • quantumsheep said:
    Yes, there's a way to do this (which I only discovered myself recently with FMG's help).

    Use a change attribute behaviour to change your actor's 'self' image.

    Here's a screenshot for the syntax related to it in the expression editor:

    https://files.me.com/qsheep/7imzn4

    Essentially what's happening here is I have six separate images. I call them stars0.png, stars1.png etc etc up to stars5.png

    The high score is a number between 0 and 5.

    What this does is negate the need to add five 'change image' behaviours, and just use one change attribute behaviour as you requested.

    I think that should work. Hope that helps!

    QS :D

    QS first off thank you for your help!!!!!
    And secondly I apologize in advanced for an newb questions I may ask! :)

    I took a look at the image you sent, so are you saying I would write the expression like this:
    "starts"..attribute..".png"

    I am new to writing any kinds of expressions! Didn't know if I was supposed to have those periods in there???

    Thanks again!
  • quantumsheepquantumsheep Member Posts: 8,188
    Hey there!

    No worries, let me clarify:

    You type directly:

    "stars"..

    then select the attribute from the drop down menu

    then immediately after the attribute you type:

    ..".png"

    So all in all it looks like "stars"..ATTRIBUTEFROMDROPDOWNMENU..".png"

    hope that helps!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • Yes you were clear the first time. : ) I just didn't know if you would be around today so I wanted to make sure I knew exactly what I need to do! I wanted to try and understand the expression more and I guess I don't know what the periods are all about. Everything else in the expression I get though
  • quantumsheepquantumsheep Member Posts: 8,188
    The periods, I believe, link the attribute to the image. I Think.

    I literally only used this for the first time two days ago, thanks to FMG.

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • Hmmmm, doesn't seem to work. : (
    Just so we were on the same page I made sure I did exactly what you said.

    I created 5 images and named them the following.
    star1.png
    star2.png
    star3.png
    And so on...

    I created an integer attribute with a default of 1 and called it "frames"

    I then apply the "change attribute" behavior to an actor in the scene.
    And set it up to do the following...

    ChangeAttribute: self.image To: "star"..attribute I created..".png"

    I then create a button that will add +1 to the attribute. I know the button works because I also set up some text to display it's value.

    So here is what works and what doesn't work...

    When I push the button and essential add +1 to the attribute the image does not change!
    But if I go back to the attribute it self and change the default value from 1 to lets say 5 and preview the scene, then the image is changed.
  • Oh hey I got it!!! I added a time to the "change attribute" that check every 0.01 secs and it works!
  • quantumsheepquantumsheep Member Posts: 8,188
    secretgamelab said:
    Oh hey I got it!!! I added a time to the "change attribute" that check every 0.01 secs and it works!

    Heh - I was about to suggest that! Glad you got it working :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

Sign In or Register to comment.