带有缓存的KineticJS:它是如何工作的?

时间:2013-08-05 12:44:31

标签: javascript caching kineticjs

我读了this tutorial并需要缓冲阶段的帮助。当用户点击“保存”时,我想要缓存场景,包括所有拖动和播放。掉元素。我真的不知道该怎么做。如果您有任何相关经验,请提供帮助。

1 个答案:

答案 0 :(得分:1)

您可以使用stage.toDataURL创建舞台的网址或图片

var myStage;

// have KineticJS convert the stage to a URL
stage.toDataURL({ 
  callback:imageDone
});

// callback after the URL has been created
// here we just make an image of the URL
function imageDone(stageDataURL){
  myStage=new Image();
  myStage.onload=function(){
      // your stage is now an image (myStage);
  }
  myStage.src=stageDataURL;
}
相关问题