GithubHelp home page GithubHelp logo

cocos-creator-giflib's Introduction

cocos creator gifLib

cocos creator gifLib 是一个cocos支持gif的库

cocos creator 版本2.0.10 (不保证其他版本支持哟) 效果如下

image image

主要是添加 添加 cc.loader.load 支持gif加载,原生平台和web平台都可以解析了

cc.loader.addDownloadHandlers({ "gif": cc.loader.downloader["extMap"].binary });
cc.loader.addLoadHandlers({
     "gif": function (item, callback) {
        let gif = new GIF();
         gif.handle(item, callback)
     }
})

用法:

image

  1. giflib添加到工程里

image

  1. 在启动场景添加如下代码,主要是注册gif解析器。这样可以在下一个场景中用到gif解析啦
  onLoad(){
        GIFCache.getInstance()
 }
  1. 在需要用到的节点上添加 GIFSprite Componet,把GIFSprite从资源管理器中拖到属性检查器中便可

image

  1. 设置gif路径和宽还有高度

设置:

  • stayAtFirstFrame: 可以让gif停到第一帧
  • fitHeight:固定图片高与maxHeight一样高,否则与加载的gif一样高
  • fitWidth:固定图片宽与maxWith一样宽,否则与加载的gif一样宽

是否添加到GIFCache中看项目中需求了

cocos-creator-giflib's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.