2014-04-04 25 views

回答

3

“原始”形状(Kinetic.Rect,Kinetic.Circle等)使用属性来定义它们的形状。

Kinetic.Shape使用上下文绘制命令来定义形状。

属性可以被序列化 - 绘图命令不能。

这就是为什么Kinetic.Shape不能完全序列化。

作为一种解决方法,请将您的sceneFunc函数保存在随页面加载的.js文件中。

例如,在myShapeSceneFuncs.js中:

// this is the sceneFunc code from var shape1=new Kinetic.Shape 

function Shape1SceneFunc(context) { 
    context.beginPath(); 
    context.moveTo(200, 50); 
    context.lineTo(420, 80); 
    context.quadraticCurveTo(300, 100, 260, 170); 
    context.closePath(); 
    // KineticJS specific context method 
    context.fillStrokeShape(this); 
} 

// rewire sceneFunc back into shape1 

shape1.sceneFunc(Shape1SceneFunc); 
相关问题