Change image size
I have been trying to make my actor to duck when pressing a duck button.
I have it almost like I want it. But it is still not right. Here is what I did. I added in a duck button, this button controls both the touch and key commands.
Then I added in a very simple change image command on my character, the only problem is that my images are two different sizes, so when he ducks he is stretched to fit the character size. How do I make it so it will adjust to the new size then go back to the other size when he is not ducking. I did try changing the height and width in the attributes, but this did not work. I have attached a few screen shots on how I have it set up. One is the touch script and the other is the character script.
Anybody have any good ideas on how to make this work?
https://www.dropbox.com/s/ml5ksj64n34w9hl/duck.zip?dl=0
thanks
Comments
"I did try changing the height and width in the attributes, but this did not work."
In what way didn't it work ?
I just made my main character distorted, not the change image
Well you could set it up so that if self.size.height = needed size :do: change image :else: change image to original image. I set up a button just like this in my game and it works just like you described the way you want it to be.
Not sure what the 'not the change image' part means . . . ? But that's all you need to do, just change the actor size to the correct size for the image, and then return the actor to the original size when the button is released.
@Socks Thanks for the reply, What I mean by "change image" This is the image I want my character to become once the button is presses.
I made some changes in the script, now when touch button is held down the image sizes changes but not on the "change image graphic)
When released the actor returned to the normal state.
I hope this makes sense... here is screen shot
https://dropbox.com/s/di650ske4rgpmvu/Screen%20Shot%202015-10-05%20at%204.24.05%20PM.png?dl=0
Ok... new development on this.. I just noticed it works some tiles..but not on all.... they are both tagged the same and have the same attributes..... any ideas
Ok, now I deleted the tiles and made new tile actors and it works.... Weird?
The only issue now is that when my character is ducking and you press the duck button and move left button the character moves left/right in a distorted image state. It takes on the original actor image but the with the duck image size.....
When left or right is pressed :do: change size to original size and original image. Then if you have an animation playing while the button is pressed it will play the animation and when it is done it will change back to the original image. Otherwise you'll have to setup additional logic for moving and crouching if you need or want that.
@jdlcrater Thanks I will give it a try. I would like to have moving and crouching, but it took me all day just to figure out how to make him duck.
@jdlcrater thanks worked perfect