CHECK IT! Need help from the pros here on the forum!!
School on Interactive Desgin
Member Posts: 68
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!!!!!!!!!!!!!!!
- 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
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
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
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!
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
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
I literally only used this for the first time two days ago, thanks to FMG.
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
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.
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io