本文介绍了如何扩展KineticJS的形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于KineticJS版本 4.0.0 或更少,形状扩展了一个类,可以扩展

For KineticJS version 4.0.0 or less a shape extended a class and could be extended by

var MyCircle = Kinetic.Circle.extend({
    init : function(config) {
        this._super(config));
    },
    myFunc : function(){}
});

Kinetic.MyCircle = function (config) {
    Kinetic.Circle.apply(this, [config]);
};
Kinetic.MyCircle .prototype = {
    myFunc: function () {}
};
Kinetic.GlobalObject.extend(Kinetic.MyCircle , Kinetic.Circle);

在版本 4.0.1 中,他们将依赖关系删除到类实用程序,

In version 4.0.1 they removed the dependencies to the class utility and implemented a custom solution that is supposed to be much faster.

如何用新的解决方案扩展形状?

How does one extend a shape with the new solution?

推荐答案

Kinetic.GlobalObject变成Kinetic.Global(> 4.0.1),然后

Kinetic.Global现在是 Kinetic.Util (2013版),这里是一个解决方案:

Kinetic.GlobalObject became Kinetic.Global (>4.0.1), then
Kinetic.Global is now Kinetic.Util (2013 versions), here is a solution:

(function() {
    Kinetic.MyCircle = function(config) {
        this._initMyCircle(config);
    };

    Kinetic.MyCircle.prototype = {
        _initMyCircle: function(config) {
            Kinetic.Circle.call(this, config);
            },
        myFunc : function(){
        }
    };

  Kinetic.Util.extend(Kinetic.MyCircle, Kinetic.Circle);
})();

这篇关于如何扩展KineticJS的形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 06:31