Quantcast
Channel: Adobe Community : All Content - Edge Animate
Viewing all articles
Browse latest Browse all 9897

Issues with Keydown and Sprite Animation

$
0
0

Please bear with me guys... I'm still learning Javascript and am new to edge.

 

I'm trying to animate a sprite sheet I made of Kirby from the NES classic, Kirby's Adventure, but am having two major problems (see video):

 

1. The sprite animation stops playing smoothly after the set label plays once on the timeline (it freezes on the first frame if I continue to hold the key down).

 

2. The sprite position will not move at all (should be moving to the right).

 

 

I've been looking at this particular thread for help, but I'm having trouble applying the fix to my code to see if it works.

 

Anyways, here is my code for keydown:

 

var spriteSheet = sym.getSymbol("spriteSheet");

//var kirbySpriteSheet = sym.getSymbolElement("kirbySpriteSheet");

// Get the jQuery handle for the element an Edge Animate Symbol Javascript Object.

 

 

 

//"d" walkRight animation

 

if (e.which == 68) {

 

spriteSheet.play("walkR");

 

 

//Move to the right

 

sym.$("spriteSheet").animate(

          {

                    right: '+=10px'

          });

 

 

 

}

 

 

And my code for keyup:

 

var spriteSheet = sym.getSymbol("spriteSheet");

var kirbySpriteSheet = sym.getSymbolElement("kirbySpriteSheet");

// insert code to be run when the user stops pressing a key.

// The variable “e.which” tells you the key code of the key that was pressed, e.g. 13 = enter

if (e.which == 68) {//stop "d", which means stop going right

          // play the timeline from the given position (ms or label)

          spriteSheet.play("standR");

 

 

}

 

 

 

If you have any suggestions, please let me know. Thank you in advance!


Viewing all articles
Browse latest Browse all 9897

Trending Articles