2014-12-08 2 views
0

createjs 라이브러리를 사용하여 스프라이트 시트 애니메이션을 만들 수있는 사람이 있는지 궁금합니다. 그래서 나는 사용자가 페이지를 열 자마자로드하고 싶은 여우의 캐릭터를 가지고 있습니다. 나는 그것을 실행하는 ok를 얻었고, 그것은 반복해서 그것을 반복한다. 그러나 나는 단지 그것이 한 번 끝나기를 원한다. 그것을 막을 수있는 방법이 있습니까 아니면 마지막 프레임에 도달했을 때 애니메이션을 멈추게 할 이벤트 리스너입니까? 어떤 도움이라도 대단히 감사 할 것입니다. 고맙습니다!스프라이트 시트를 한 번만 실행하십시오. createjs

function projectFox() { 

    createjs.Ticker.addEventListener("tick", stage); 
    createjs.Ticker.setFPS(8); 
    foxanimation(); 

    function foxanimation() { 

    var data = { 

    "images": ["images/foxes.png"], 
    "frames": [ 

     [2, 2, 833, 833], 
     [2507, 837, 833, 833], 
     [3342, 1672, 833, 833], 
     [3342, 2507, 833, 833], 
     [4177, 837, 833, 833], 
     [5012, 837, 833, 833], 
     [4177, 1672, 833, 833], 
     [4177, 2507, 833, 833], 
     [5012, 1672, 833, 833], 
     [5012, 2507, 833, 833], 
     [2, 837, 833, 833], 
     [2, 1672, 833, 833], 
     [2, 2507, 833, 833], 
     [837, 2, 833, 833], 
     [837, 837, 833, 833], 
     [837, 1672, 833, 833], 
     [837, 2507, 833, 833], 
     [1672, 2, 833, 833], 
     [1672, 837, 833, 833], 
     [1672, 1672, 833, 833], 
     [1672, 2507, 833, 833], 
     [2507, 2, 833, 833], 
     [2507, 1672, 833, 833], 
     [2507, 2507, 833, 833], 
     [3342, 2, 833, 833], 
     [4177, 2, 833, 833], 
     [5012, 2, 833, 833], 
     [3342, 837, 833, 833] 

    ], 

    "animations": { 

      "start":{frames:[0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 1, 0]}, 
      "blink":{frames:[0, 7, 8, 7, 0]}, 
      "sleep":{frames:[0, 9, 10, 11, 12, 0]}, 
      "where":{frames:[0, 13, 14, 15, 16, 17, 18, 13, 0]}, 
      "love":{frames:[0, 19, 20, 21, 22, 23, 24, 23, 22, 0]}, 
      "tail":{frames:[0, 25, 0, 26, 27, 0, 25, 0, 26, 27, 0]} 

    } 
    }; 

    var spritesheet = new createjs.SpriteSheet(data); 
    var intro = new createjs.Sprite(spritesheet,'start'); 

    var introBounds = intro.getBounds(); 
    intro.regX = introBounds.width/2; 
    intro.regY = introBounds.height/2; 
    intro.scaleX=0.5; 
    intro.scaleY=0.5; 
    intro.x = stageW/2; 
    intro.y = stageH/2; 
    intro.cursor = "pointer"; 

    stage.addChild(intro); 

    stage.update(); 
    } 

답변

0

당신처럼 할 수있는이

function projectFox() { 

createjs.Ticker.addEventListener("tick", stage); 
createjs.Ticker.setFPS(8); 
foxanimation(); 

function foxanimation() { 

var data = { 

"images": ["images/foxes.png"], 
"frames": [ 

    [2, 2, 833, 833], 
    [2507, 837, 833, 833], 
    [3342, 1672, 833, 833], 
    [3342, 2507, 833, 833], 
    [4177, 837, 833, 833], 
    [5012, 837, 833, 833], 
    [4177, 1672, 833, 833], 
    [4177, 2507, 833, 833], 
    [5012, 1672, 833, 833], 
    [5012, 2507, 833, 833], 
    [2, 837, 833, 833], 
    [2, 1672, 833, 833], 
    [2, 2507, 833, 833], 
    [837, 2, 833, 833], 
    [837, 837, 833, 833], 
    [837, 1672, 833, 833], 
    [837, 2507, 833, 833], 
    [1672, 2, 833, 833], 
    [1672, 837, 833, 833], 
    [1672, 1672, 833, 833], 
    [1672, 2507, 833, 833], 
    [2507, 2, 833, 833], 
    [2507, 1672, 833, 833], 
    [2507, 2507, 833, 833], 
    [3342, 2, 833, 833], 
    [4177, 2, 833, 833], 
    [5012, 2, 833, 833], 
    [3342, 837, 833, 833] 

], 

"animations": { 

     "start":{ 
       frames:[0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 1, 0], 
       next: false 
        }, 

     "blink":{ 
       frames:[0, 7, 8, 7, 0], 
       next: false 
       }, 

     "sleep":{ 
       frames:[0, 9, 10, 11, 12, 0], 
       next: false 
       }, 

     "where":{ 
       frames:[0, 13, 14, 15, 16, 17, 18, 13, 0], 
       next: false 
       }, 

     "love":{ 
       frames:[0, 19, 20, 21, 22, 23, 24, 23, 22, 0], 
       next: false 
       }, 

     "tail":{ 
      frames:[0, 25, 0, 26, 27, 0, 25, 0, 26, 27, 0], 
       next: false 
      } 

} 
}; 



var spritesheet = new createjs.SpriteSheet(data); 
    var intro = new createjs.Sprite(spritesheet,'start'); 

    var introBounds = intro.getBounds(); 
    intro.regX = introBounds.width/2; 
    intro.regY = introBounds.height/2; 
    intro.scaleX=0.5; 
    intro.scaleY=0.5; 
    intro.x = stageW/2; 
    intro.y = stageH/2; 
    intro.cursor = "pointer"; 

    stage.addChild(intro); 

    stage.update(); 
    } 
+0

큰, 즉 일! 고맙습니다! 그래서 나중에 한 번만 실행하면 무대에서 제거 될 것입니다. if 문을 작성해야합니까? :에스 – jvan27

관련 문제