# Platform Game Animations

**URL:** <https://forum.kirupa.com/t/platform-game-animations/285207>\
**Category:** programming\
**Created:** [March 28, 2009, 3:58pm UTC](https://forum.kirupa.com/t/platform-game-animations/285207 "2009-03-28T15:58:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason116](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@jason116](https://forum.kirupa.com/u/jason116)\
**Post date:** [March 28, 2009, 3:58pm UTC](https://forum.kirupa.com/t/platform-game-animations/285207/1 "2009-03-28T15:58:33Z")

</div>

Has anyone got any good techniques for playing different character animations on key presses in platform games. So far I have a player MovieClip with nested animation movieclips set on different frames but in my code when i try the following :

[AS]  
// moveRight is a boolean variable for if the right button is pressed  
// moveLeft is a boolean variable for if the left button is pressed

// walking is a frame label in the player movieclip  
// idle is a frame label in the player movieclip

[//Physics.PLAYERSPEED](https://Physics.PLAYERSPEED) is an integer for moving the player

```
        if(moveRight) {
            if(this.currentFrame != 2) {
            this.x += Physics.PLAYERSPEED;
            this.gotoAndStop("walking"); 
            }
        }
        else if(moveLeft) {
            if(this.currentFrame != 2) {
            this.x -= Physics.PLAYERSPEED; 
            this.gotoAndStop("walking");
            }
        }
        else {
            this.gotoAndStop("idle");
        }

```

[/AS]

The above code plays the animation once but dont loop like I thought it would ?

Thanks
