cocosjs gaf动画

loadAnimation: function(name){

        if(this._anim)

        {

            this.removeChild(this._anim);

            this._anim = null;

        }

        var self = this;

        var asset = gaf.Asset.create(name);

        var onLoad = function(){

            var size = cc.winSize;

            var a = self._anim = asset.createObjectAndRun(true);

            self._anim.setAnimationRunning(true, true);

            a.setAnchorPoint(0.5, 0.5);

            a.setPosition(size.width/2, size.height/2);

            self.addChild(a,105);

            var names = a.getSequences();

            cc.log(names)

            // self.setSequnces(Object.keys(names));

            var sceneColor = self._anim._gafproto.getAsset().getSceneColor();

            if (sceneColor)

            {

                self.setColor(sceneColor);

            }

        };

        if(asset.addEventListener)

        {

            // Only JS library loads assets async

            asset.addEventListener("load", onLoad);

        }

        else

        {

            // JSB load resources sync and have no method `addEventListener`

            onLoad();

        }

    }

调用 this.loadAnimation('source/christmas2013_julia2.gaf');

参考http://www.taikr.com/article/1978

你可能感兴趣的:(cocosjs gaf动画)