Cocos2d-x动画工具类
1.此工具类的目的是为了方便执行动画,使用TexturePackerGUI工具可以导出plist文件和png图片,这里我示例图片叫bxjg.plist和bxjg.png //////////////////////////////////////.h文件 #ifndef _AnimateUtil_H_ #define _AnimateUtil_H_ #include cocos2d.h us
1.此工具类的目的是为了方便执行动画,使用TexturePackerGUI工具可以导出plist文件和png图片,这里我示例图片叫bxjg.plist和bxjg.png
//////////////////////////////////////.h文件
#ifndef _AnimateUtil_H_
#define _AnimateUtil_H_#include "cocos2d.h"
using namespace cocos2d;
using namespace std;
class AnimateUtil//动画工具类
{
public:
//根据文件名字前缀创建动画对象 名称 播放的间隔 是否循环播放
static Animation * createWithSingleFrameName(const char * name, float delay, int Loops);
//根据文件名字前缀创建动画对象,指定动画图片数量 名称 图片数量 播放的间隔 是否循环播放
static Animation * createWithFrameNameAndNum(const char * name, int num, float delay, int Loops);
};
#endif
/////////////////////////////////.cpp文件
#include "AnimateUtil.h"
Animation * AnimateUtil::createWithSingleFrameName(const char * name, float delay, int Loops)
{
/*将图片加载到精灵帧缓冲池*/
SpriteFrameCache *frameCache = SpriteFrameCache::getInstance();
Vector
SpriteFrame * frame = NULL;
int index = 1;//小图片数量
do
{
//从SpriteFrame缓冲池获取SpriteFrame对象
frame = frameCache->getSpriteFrameByName(StringUtils::format("%s%d.png", name, index++));
//不断获取spriteFrame对象,直到获取的值为NULL
if (frame == NULL)
{
break;
}
frameVec.pushBack(frame);
} while (true);
//使用SpiteFrame列表创建动画对象
Animation * animation = Animation::createWithSpriteFrames(frameVec);
animation->setLoops(Loops);//设置是否循环
animation->setRestoreOriginalFrame(true);
animation->setDelayPerUnit(delay);//设置动画间隙
return animation;
}
Animation * AnimateUtil::createWithFrameNameAndNum(const char * name, int num, float delay, int Loops)
{
SpriteFrameCache * frameCache = SpriteFrameCache::getInstance();
SpriteFrame * frame = NULL;
Vector
int index = 1;
for (int i = 1; i
{
frame = frameCache->getSpriteFrameByName(StringUtils::format("%s%d.png", name, index++));
if (frame ==NULL)
{
break;
}
frameVec.pushBack(frame);
}
Animation * animation = Animation::createWithSpriteFrames(frameVec);
animation->setLoops(Loops);
animation->setRestoreOriginalFrame(true);
animation->setDelayPerUnit(delay);
return animation;
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











In the cryptocurrency market, choosing a reliable trading platform is crucial. As a world-renowned digital asset exchange, the OK trading platform has attracted a large number of novice users in mainland China. This guide will introduce in detail how to register and use it on the OK trading platform to help novice users get started quickly.

The world's leading cryptocurrency trading platform is famous for its efficient, secure and diverse trading services. Whether you are an experienced trader or a newbie into the cryptocurrency market, Binance has the tools and resources you need. Through Binance web version, users can easily access the trading platform without downloading any applications and conduct trading operations directly through the browser. This article will introduce in detail how to enter the Binance Binance Exchange web version and provide some practical trading tips and precautions.

A world-renowned digital currency trading platform, established in 2014, is committed to providing users with safe and convenient digital asset trading services. As an international exchange, Yiou supports the transaction of a variety of mainstream and niche digital currencies, attracting users from all over the world. Whether newbies or experienced traders, you can find trading tools and services that suit you on the Yiou platform.

Recommended exchanges for bull market in May 2025: 1. Binance; 2. OKX; 3. Huobi; 4. gate.io; 5. Sesame Open Door and other exchanges. The above exchanges are safe and reliable, and support a variety of currencies. This article provides detailed download portal addresses.

Recommended exchanges for bull market in May 2025: 1. Binance; 2. OKX; 3. Huobi; 4. gate.io; 5. Sesame Open Door and other exchanges. The above exchanges are safe and reliable, and support a variety of currencies. This article provides detailed download portal addresses.

As the world's leading digital asset trading platform, it has attracted a large number of investors and traders with its efficient, secure and user-friendly experience. Whether you are a first-time cryptocurrency market or an experienced trading expert, Ouyi OKX provides a wealth of trading tools and services to meet the needs of users at different levels. Recently, Ouyi OKX released the latest official link to ensure that users can access the platform safely and conveniently, conduct transactions and asset management.

Do you want to know how to use cookies on your WordPress website? Cookies are useful tools for storing temporary information in users’ browsers. You can use this information to enhance the user experience through personalization and behavioral targeting. In this ultimate guide, we will show you how to set, get, and delete WordPresscookies like a professional. Note: This is an advanced tutorial. It requires you to be proficient in HTML, CSS, WordPress websites and PHP. What are cookies? Cookies are created and stored when users visit websites.

Do you see the "429 too many requests" error on your WordPress website? This error message means that the user is sending too many HTTP requests to the server of your website. This error can be very frustrating because it is difficult to find out what causes the error. In this article, we will show you how to easily fix the "WordPress429TooManyRequests" error. What causes too many requests for WordPress429? The most common cause of the "429TooManyRequests" error is that the user, bot, or script attempts to go to the website
