2011-09-27 2 views
1

이 플러그인을 사용하고 있습니다. http://www.spritely.net/ 변수 $ 스프라이트가 다시 실행되지 않는 이유는 누구에게 말해 줄 수 있습니까?jquery spritefy 일시 중지 및 다시 시작

function animate_header() { 
    $('#header') 
     .sprite({ 
      fps: 30, 
      no_of_frames: 4, 
      // the following are optional: new in version 0.6... 
      start_at_frame: 1, 
      rewind: false, 
      on_last_frame: function(obj) { 
       // you could stop the sprite here with, e.g. 
       obj.spStop(); 
      } 
     }) 
     .active(); 
} 
var init = setInterval("animate_header()", 1000); 

함수 자체가 매초 실행 :

function animate_header() { 
    var $sprite = $('#header') 
     .sprite({ 
      fps: 30, 
      no_of_frames: 4, 
      // the following are optional: new in version 0.6... 
      start_at_frame: 1, 
      rewind: false, 
      on_last_frame: function(obj) { 
       // you could stop the sprite here with, e.g. 
       obj.spStop(); 
      } 
     }) 
     .active(); 
} 
var init = setInterval("animate_header()", 1000); 

는 또한이 시도. 그러나 스프라이트는 그렇지 않습니다.

+0

수정을 파괴)? 나는 spritely의 방법으로 그것을 보지 않는다 (또는 jQuery 함수인가?). – orolo

+0

죄송합니다. 표시됩니다. .destroy()를 호출하고 다시 실행 해 보았습니까? – orolo

답변

0

나는이 일을 결국 ... 그것은 가야 점프 시작을 필요로 마지막 프레임에서 호출됩니다 obj.spStop()처럼 보인다. 내가 원하는대로 일했습니다.

function loop() { 

    $('#bird').sprite({fps: 7, no_of_frames: 4, play_frames: 4}); 

      var t = setTimeout(function(){ 
      loop() 
      }, 2000); 
     } 
     loop() 

답장을 보내 주셔서 감사합니다.

이 우연히 발견 일어날 수있는 다른 사람들을위한
3

이것이 저에게 효과적입니다. 먼저 옵션을 설정 한 다음 spStart 함수로 반복했습니다. 코드의 끝 부분에 .spStart();.active();를 교체

$('#header') 
    .sprite({ 
     fps: 30, 
     no_of_frames: 4, 
     start_at_frame: 1, 
     rewind: false, 
     on_last_frame: function(obj) { 
      // you could stop the sprite here with, e.g. 
      obj.spStop(); 
     } 
    }); 

setInterval ("$('#header').spStart()", 1000); 
0

시도.

은 죽은 애니메이션을 죽이고 그 나를 위해 일했다 :)

1

.destroy() 

애니메이션은 다른 모든 방법으로 몇 번을 실행 한 후 휴식 것 같다 사용하지만 (이 :) .active는 무엇

+0

정말 유용합니다. 사용법을 조금만 설명하면 다른 사람들이 훨씬 쉽게 사용할 수 있습니다. –