Saturday, 15 January 2011

javascript - EaselJS Sprite gotoAndPlay won't loop -


I used EaselJS to animate a single sprite. I used the gotoandplay to animate while rotating my code while using the point of right and left to move it, but my phantom only makes an animation once Closes on the last frame I tried to change the frequency to activate the loop, but nothing works I hope you can understand where my fault is, thank you my code here:

  var stage, img = new image (), bg = new image (), bgbitmap, link , Text, clavier = {gauche: 0, droite: 0}; Press the window.onkeydown = key; Window.onkeyup = key release; Press the function key (e) {var i; If (e.keycode == 37) {clavier.gauche = 1; {Link.gotoAndPlay ("wkLeft") for (i = 0; i & lt; 10; i ++); }} If (e.keyCode ==39) {clavier.droite = 1; Link.gotoAndPlay ("wkRight"); }} Function key Releases (e) {if (e.keycode == 37) {clavier.gauche = 0; Link.gotoAndPlay ("Stand"); } If (e.keycode ==39) {clavier.droite = 0; Link.gotoAndPlay ("Stand"); }} Function init () {stage = new createj.Stage ('mon_canvas'); Bg.src = "img / bg.png"; Bg.onload = creationBg (); Img.src = "img / img.png"; Img.onload = creationPerso (); Createjs.Ticker.useRAF = true; Createjs.Ticker.setFPS (60); Createjs.Ticker.addEventListener ("Tic", forums); Createjs.Ticker.addEventListener ("Tic", Tic); } Function Creation Parso () {var ss = new createjs.SpriteSheet ({images: [img], frame: {height: 90, width: 90, regX: 45, regy: 45}, animation: {wkRight: {frames: 5, 9, true, 6], speed: 0.1}, stand: [15], wk lift: {frame: [0, 4, truth, 6], speed: 0.1}}}); Link = new createjs.Sprite (SS, "stand"); Link.x = stage.canvas.width / 2; Link.y = 280; Stage.addChild (link); } Function tick () {non (;); Scene.update (); } Function creation () {bgBitmap = new createjs.Bitmap (bg); BgBitmap.regX = 400; BgBitmap.regY = 300; BgBitmap.x = 400; BgBitmap.y = 100; BgBitmap.scaleX = 1; Bgbitmap.scaleY = 1; Stage.addChild (bgBitmap); } Function displacement () {if (clavier.gauche == 1) {link.x = link.x - 1; } If (clavier.droite == 1) {link.x = link.x + 1; }} Window.onload = init; Your sprite sheet format is not correct You have used long form animation format, Where  frames  should include a list of frame numbers - but you've used  59, true, 6  - which looks like a short form (start, end, next, Speed) 

  var ss = new createjs.SpriteSheet ({Image: [img], frame: {height: 90, width: 90, regX: 45, regy : 45}, animation: {wkRight: [5, 9, true, 0.1] stand: [15], wk lift: [0, 4, true, 0.1]}});  

Note that if your walking animation is flipped just left / right on the liquid, then you can use the phantom by using scaleX = -1 You can flip, which reduces the number of frames to your sprite sheet.

Let me know that it helps if you post a sample, maybe will help on JSFiddle. Here is a sprite sheet sample I've used:


No comments:

Post a Comment