Need assistance with change of sprite bug. :)
TwilightHunter
Member Posts: 146
Hey, I have a slight issue in my actor when he is walking around. He moves up, down, left and right, and he changes his sprite accordingly by showing an animation. (I'm using the "Move" function by the way) My problem is this: When you hit the up key, and then hold the left key at the same time, the actor's sprite glitches between left and right sprites. I'll try and explain how I'm moving the character and changing sprite more clearly:
Move Left Rule:
Play Animation -Walk left 1, 2, 3.
If left key is down:
Move 270 degrees(I think that's left) at speed of 100.
Otherwise:
Change image to Walk left 2 (Stand facing left)
That is about how it is coded. Hope that helps, thanks in advance!
Move Left Rule:
Play Animation -Walk left 1, 2, 3.
If left key is down:
Move 270 degrees(I think that's left) at speed of 100.
Otherwise:
Change image to Walk left 2 (Stand facing left)
That is about how it is coded. Hope that helps, thanks in advance!
Comments
If you are looking straight top-down, you can either add logic to accomodate two-button presses at the same time (i.e. up and left as in your example) that then takes advantage of 8 directions of animation. Or you can have one direction of animation (i.e. top-down of head/torso with arm swings and feet popping in-n-out in front and behind) and use rotation to adjust direction.
If it is three-quarter view (i.e. top-down angled or isometric), you will probably want to animate 8 directions.
An alternative to animating in 8 directions for either top-down or isometric would be to limit input to the 4 directions that are animated. Have a game level boolean attribute that keeps track of if a key press is already down - then don't act on another key press. When a key press is encountered, set the attribute to "true" only if it is currently "false" and then allow the movement setting it back to "true" upon key press end (trying to think if GS accounts for key up...touch up I'm pretty sure is there for the screen...not at my Mac). If upon key press, the attribute is already "false", don't allow the movement.
I don't think you are talking about a side-scrolling shooter.
If a side-scrolling platformer with say left/right movement and climbing up/down...the aforementioned boolean method comes into play again, only this time, you will label the attribute "IsClimbing" or something similar to control which animation(s) come into play.
Remove the otherwise section, you don't need it. Just uncheck 'restore actor image when done' that way he is still facing left when you let up.
When Up is pressed Play Animation Up 1,2,3
When Down is pressed Play Animation Down 1,2,3
When Left is pressed Play Animation Left 1,2,3
When Right is pressed Play Animation Right 1,2,3
-------------------------------------------------------------------------------
When Up is pressed &
When Left is pressed Play Animation Up 1,2,3
-------------------------------------------------------------------------------
When Up is pressed &
When Right is pressed Play Animation Up 1,2,3
-------------------------------------------------------------------------------
When Down is pressed &
When Left is pressed Play Animation Down 1,2,3
-------------------------------------------------------------------------------
When Down is pressed &
When Right is pressed Play Animation Down 1,2,3
-------------------------------------------------------------------------------
Obviously you can substitute the animations. So if you are pressing UP + Left & you don't want to animate the Up 1,2,3, you can animate Left 1,2,3. This make sense?
This is theory, haven't tested it, but 'should' work.
What view angle is your game?
Are up-n-down walking, climbing, jumping, or?