COCOS2DX 3.x play GIF using a third-party library

Source: Internet
Author: User
Tags addchild


Because GIF is needed for KD projects, the COCOS2DX itself does not support GIF playback. Baidu + Google for a long time, and ultimately point to https://github.com/opentalking/gif-for-cocos2dx here, but the first to see the time is based on 2.2, because the underlying code is not familiar with, there is no way to start ... So contact the original author, he made a 3.x version of a weekend, we can go to worship https://github.com/opentalking/gif-for-cocos2dx-3.x.git

Here sincerely to the great God of the selfless sharing of the spirit of praise ~

How to use:
pull down, import the GIF folder into the project, then you can use gif~~~

like a sprite.

std::string name =" G2.gif "; name = Fileutils::getinstance (), Fullpathforfilename ( Name.c_str ()); Gifbase *gif = Instantgif::create (Name.c_str ()); Gif->setposition (Point (visiblesize.width * 0.5, Visiblesize.height * 0.5); GIF, Setscale (2); this->addchild (GIF); gif2 = Cachegif::create (Name.c_str ()); gif2- >setposition (Point (500,0)); Gif2->setscale (2); This->addchild (GIF2);  

Use of the class is mainly instantgif and cachegif, the use of the same method, the former is playing one side from the data to parse the frame, the latter is a one-time parsing, and put in the cache, this way takes long, occupy memory large (picture frame number too many words may hang), But the first way will be a lot smoother ~

Welcome to my blog: helkyle.tk

COCOS2DX 3.x play GIF using a third-party library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.