Need assistance with change of sprite bug. :)

TwilightHunterTwilightHunter Member Posts: 146
edited November -1 in Working with GS (Mac)
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!

Comments

  • rebumprebump Member Posts: 1,058
    Well, if you only have 4 directions of animation but allow for 8 directions of travel, there will be obvious jerky switches between the two animation directions (i.e. up and left in your example).

    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.
  • JGary321JGary321 Member Posts: 1,246
    Whats happening is that it's trying to complete both commands. Try this:

    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.
  • TwilightHunterTwilightHunter Member Posts: 146
    Hey thanks a lot! I'll be trying JGary's theory first, (Seems the easiest, I'm a little lazy when it comes to big lines). Anyway, thanks again, I'll try em now :P
  • rebumprebump Member Posts: 1,058
    JGary's suggestion sounds workable and would be easier to implement but then you get up and down movement with a moonwalk effect which works fine for many games. However, if you implement JGary's suggestion and the up-n-down movement is say climbing and you default to up-n-down movement when multiple keys are pressed, you are golden (i.e. if on the ladder, you stay in the climbing animation but can move left or right).

    What view angle is your game?

    Are up-n-down walking, climbing, jumping, or?
  • TwilightHunterTwilightHunter Member Posts: 146
    Ok, so I was trying JGary's post. It almost fixed my issue the problem still wanted to persist. And yes, Rebump, the game is indeed a top down game, I guess just imagine one of those old Final Fantasy engines of movement. I'll add some variables (attributes, whateva they call em in here) and try not to let multiple movement keys pressed at the same time. Thanks again :)
  • TwilightHunterTwilightHunter Member Posts: 146
    Actually... How do I go about setting attributes? I could never figure it out before. 8P
  • TwilightHunterTwilightHunter Member Posts: 146
    Nevermind, I think I got it. hehe
Sign In or Register to comment.