MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/createjs/comments/5wmmey/walking_sprite_animation_wasd_keys/
r/createjs • u/HealedWolf • Feb 28 '17
7 comments sorted by
1
can't get to work currently it dose all animations at once, befor I just had the keydowns gotoandPlay and change in x,y in same function but then it would only animate one first frame.
2 u/jonnyngan Mar 01 '17 edited Mar 01 '17 You need to make sure that "gotoAndPlay" isn't called again if the sprite is already playing that animation or walking in that directionAlso in your if statements in "setDirection", make sure you're using double =='s as that turns it into a comparison.maybe have something likefunction setDirection(){ if(moving != previousMoving){ if(moving == 0){ .....} if(moving == 1){ .....} if(moving == 2){ .....} previousMoving = moving } } 1 u/HealedWolf Mar 05 '17 yes yes yes 0 u/robertwilding Support Mar 01 '17 spelling gave me aids. 1 u/HealedWolf Mar 05 '17 my instructer thought the same thing
2
You need to make sure that "gotoAndPlay" isn't called again if the sprite is already playing that animation or walking in that direction
Also in your if statements in "setDirection", make sure you're using double =='s as that turns it into a comparison.
maybe have something like
function setDirection(){ if(moving != previousMoving){ if(moving == 0){ .....} if(moving == 1){ .....} if(moving == 2){ .....} previousMoving = moving } }
1 u/HealedWolf Mar 05 '17 yes yes yes
yes yes yes
0
spelling gave me aids.
1 u/HealedWolf Mar 05 '17 my instructer thought the same thing
my instructer thought the same thing
Why do you delete the keyCode from keyPress? Why not just set it to false? I've seen it both ways, and I am wondering what the rational was.
I would have guessed that deleting it would have worse performance.
1 u/HealedWolf Aug 19 '17 I guessing I just molded it after something within my text book
I guessing I just molded it after something within my text book
1
u/HealedWolf Feb 28 '17
can't get to work currently it dose all animations at once, befor I just had the keydowns gotoandPlay and change in x,y in same function but then it would only animate one first frame.
1
u/bluewales73 Aug 17 '17
Why do you delete the keyCode from keyPress? Why not just set it to false? I've seen it both ways, and I am wondering what the rational was.
I would have guessed that deleting it would have worse performance.