cocos2d-x节点(CCAnimation.h)API

2023-10-19 20:08
文章标签 api 节点 cocos2d ccanimation

本文主要是介绍cocos2d-x节点(CCAnimation.h)API,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

本文来自http://blog.csdn.net/runaying ,引用必须注明出处!

cocos2d-x节点(CCAnimation.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

//创建帧动画

///cocos2d-x-3.0alpha0/cocos2dx/sprite_nodes
//创建帧动画#ifndef __CC_ANIMATION_H__
#define __CC_ANIMATION_H__#include "platform/CCPlatformConfig.h"
#include "cocoa/CCObject.h"
#include "cocoa/CCArray.h"
#include "cocoa/CCDictionary.h"
#include "cocoa/CCGeometry.h"
#include "CCSpriteFrame.h"
#include <string>NS_CC_BEGINclass Texture2D;
class SpriteFrame;/*** @addtogroup sprite_nodes* @{*//** AnimationFrame一帧动画。它包含的信息,如:- sprite frame name             //精灵的框架名称- # of delay units.             //延迟单元- offset                        //偏移@since v2.0*/
class CC_DLL AnimationFrame : public Object, public Clonable
{
public:/*** @js ctor*/AnimationFrame();/*** @js NA* @lua NA*/virtual ~AnimationFrame();/** 使用 spriteframe,延迟单元数,用户通知 初始化一个帧动画 */bool initWithSpriteFrame(SpriteFrame* spriteFrame, float delayUnits, Dictionary* userInfo);SpriteFrame* getSpriteFrame() const { return _spriteFrame; };void setSpriteFrame(SpriteFrame* frame){CC_SAFE_RETAIN(frame);CC_SAFE_RELEASE(_spriteFrame);_spriteFrame = frame;}/** 获取帧需要的单位时间 */float getDelayUnits() const { return _delayUnits; };/** Sets 帧需要的单位时间 */ void setDelayUnits(float delayUnits) { _delayUnits = delayUnits; };/** @brief 获取用户详细资料框架显示本字典的用户信息,一个AnimationFrameDisplayedNotification通知会广播,如果用户信息是 nil,那么没有通知将播出*/Dictionary* getUserInfo() const { return _userInfo; };/** Sets user infomation */void setUserInfo(Dictionary* userInfo){CC_SAFE_RETAIN(userInfo);CC_SAFE_RELEASE(_userInfo);_userInfo = userInfo;}// Overridesvirtual AnimationFrame *clone() const override;protected:/** SpriteFrameName to be used */SpriteFrame* _spriteFrame;/**  帧需要的单位时间  */float _delayUnits;/**  框架显示本字典的用户信息,一个AnimationFrameDisplayedNotification通知会广播,如果用户信息是 nil,那么没有通知将播出. */Dictionary* _userInfo;
};/** 动画对象用于执行Sprite动画.动画的对象包含 AnimationFrame 对象, 帧之间的延迟.
您可以通过使用动画动作作为动画对象. Example:@codesprite->runAction(Animate::create(animation));
@endcode*/
class CC_DLL Animation : public Object, public Clonable
{
public:/** Creates an animation@since v0.99.5*/static Animation* create(void);/* 使用 AnimationFrame 数组,帧之间的延迟 创建一个动画将在帧上添加一个 "delay unit".@since v0.99.5*/static Animation* createWithSpriteFrames(Array* arrayOfSpriteFrameNames, float delay = 0.0f);/* 使用 AnimationFrame 数组,帧之间的延迟(每隔多久会执行) 创建一个动画@since v2.0* @js NA*/static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops = 1);/*** @js ctor*/Animation();/*** @js NA* @lua NA*/virtual ~Animation(void);bool init();/** 使用 Frame,帧之间的延迟(每隔多久会执行) 初始化一个动画@since v0.99.5*/bool initWithSpriteFrames(Array *pFrames, float delay = 0.0f);/** 使用 AnimationFrame 初始化一个动画@since v2.0*/bool initWithAnimationFrames(Array* arrayOfAnimationFrames, float delayPerUnit, unsigned int loops);/** 添加一个 SpriteFrame 到一个 Animation将在帧上添加一个 "delay unit".*/void addSpriteFrame(SpriteFrame *pFrame);/** Adds a frame with an image filename. 内部它将创建一个SpriteFrame并添加它将在帧上添加一个 "delay unit".Added to facilitate the migration from v0.8 to v0.9.*/void addSpriteFrameWithFile(const char *filename);/**@deprecated. Use addSpriteFrameWithFile() instead*/CC_DEPRECATED_ATTRIBUTE void addSpriteFrameWithFileName(const char *filename){ addSpriteFrameWithFile(filename);}/** Adds a frame with a texture and a rect. 内部它将创建一个SpriteFrame并添加它将在帧上添加一个 "delay unit".加入它帮助你从V0.8迁移到V0.9.*/void addSpriteFrameWithTexture(Texture2D* pobTexture, const Rect& rect);/** Gets 单元动画总延迟. */float getTotalDelayUnits() const { return _totalDelayUnits; };/** Sets "delay unit"(延迟单元) 以秒为单位 */void setDelayPerUnit(float delayPerUnit) { _delayPerUnit = delayPerUnit; };/** Gets "delay unit"(延迟单元) 以秒为单位 */float getDelayPerUnit() const { return _delayPerUnit; };/** Gets 整个动画的持续时间以秒为单位。它的结果是的 totalDelayUnits * delayPerUnit */float getDuration() const;/** Gets the array of AnimationFrames */Array* getFrames() const { return _frames; };/** Sets the array of AnimationFrames */void setFrames(Array* frames){CC_SAFE_RETAIN(frames);CC_SAFE_RELEASE(_frames);_frames = frames;}/** Checks 完成动画时,是否恢复原来的帧. */bool getRestoreOriginalFrame() const { return _restoreOriginalFrame; };/** Sets 完成动画时,是否恢复原来的帧 */void setRestoreOriginalFrame(bool restoreOriginalFrame) { _restoreOriginalFrame = restoreOriginalFrame; };/** Gets 循环动画。 0表示动画不是动画。 1,动画执行一次, ... */unsigned int getLoops() const { return _loops; };/** Sets 循环动画。 0表示动画不是动画。 1,动画执行一次, ... */void setLoops(unsigned int loops) { _loops = loops; };// overridesvirtual Animation *clone() const override;protected:/** 动画总共有多少个延迟单元. */float _totalDelayUnits;/** Delay in seconds of the "delay unit" */float _delayPerUnit;/** 整个动画的持续时间以秒为单位。它的结果是的 totalDelayUnits * delayPerUnit */float _duration;/** array of AnimationFrames */Array* _frames;/** 完成时是否应恢复原来的帧动画 */bool _restoreOriginalFrame;/** 多少次循环动画。 0表示动画不是动画。 1,动画执行一次, ... */unsigned int _loops;
};// end of sprite_nodes group
/// @}NS_CC_END#endif // __CC_ANIMATION_H__


这篇关于cocos2d-x节点(CCAnimation.h)API的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/242076

相关文章

SpringBoo WebFlux+MongoDB实现非阻塞API过程

《SpringBooWebFlux+MongoDB实现非阻塞API过程》本文介绍了如何使用SpringBootWebFlux和MongoDB实现非阻塞API,通过响应式编程提高系统的吞吐量和响应性能... 目录一、引言二、响应式编程基础2.1 响应式编程概念2.2 响应式编程的优势2.3 响应式编程相关技术

java中4种API参数传递方式统一说明

《java中4种API参数传递方式统一说明》在Java中,我们可以使用不同的方式来传递参数给方法或函数,:本文主要介绍java中4种API参数传递方式的相关资料,文中通过代码介绍的非常详细,需要的... 目录1. 概述2. 参数传递方式分类2.1 Query Parameters(查询参数)2.2 Path

Java调用DeepSeek API的8个高频坑与解决方法

《Java调用DeepSeekAPI的8个高频坑与解决方法》现在大模型开发特别火,DeepSeek因为中文理解好、反应快、还便宜,不少Java开发者都用它,本文整理了最常踩的8个坑,希望对... 目录引言一、坑 1:Token 过期未处理,鉴权异常引发服务中断问题本质典型错误代码解决方案:实现 Token

使用Go调用第三方API的方法详解

《使用Go调用第三方API的方法详解》在现代应用开发中,调用第三方API是非常常见的场景,比如获取天气预报、翻译文本、发送短信等,Go作为一门高效并发的编程语言,拥有强大的标准库和丰富的第三方库,可以... 目录引言一、准备工作二、案例1:调用天气查询 API1. 注册并获取 API Key2. 代码实现3

PHP应用中处理限流和API节流的最佳实践

《PHP应用中处理限流和API节流的最佳实践》限流和API节流对于确保Web应用程序的可靠性、安全性和可扩展性至关重要,本文将详细介绍PHP应用中处理限流和API节流的最佳实践,下面就来和小编一起学习... 目录限流的重要性在 php 中实施限流的最佳实践使用集中式存储进行状态管理(如 Redis)采用滑动

Go语言使用net/http构建一个RESTful API的示例代码

《Go语言使用net/http构建一个RESTfulAPI的示例代码》Go的标准库net/http提供了构建Web服务所需的强大功能,虽然众多第三方框架(如Gin、Echo)已经封装了很多功能,但... 目录引言一、什么是 RESTful API?二、实战目标:用户信息管理 API三、代码实现1. 用户数据

Python用Flask封装API及调用详解

《Python用Flask封装API及调用详解》本文介绍Flask的优势(轻量、灵活、易扩展),对比GET/POST表单/JSON请求方式,涵盖错误处理、开发建议及生产环境部署注意事项... 目录一、Flask的优势一、基础设置二、GET请求方式服务端代码客户端调用三、POST表单方式服务端代码客户端调用四

SpringBoot结合Knife4j进行API分组授权管理配置详解

《SpringBoot结合Knife4j进行API分组授权管理配置详解》在现代的微服务架构中,API文档和授权管理是不可或缺的一部分,本文将介绍如何在SpringBoot应用中集成Knife4j,并进... 目录环境准备配置 Swagger配置 Swagger OpenAPI自定义 Swagger UI 底

使用Python的requests库调用API接口的详细步骤

《使用Python的requests库调用API接口的详细步骤》使用Python的requests库调用API接口是开发中最常用的方式之一,它简化了HTTP请求的处理流程,以下是详细步骤和实战示例,涵... 目录一、准备工作:安装 requests 库二、基本调用流程(以 RESTful API 为例)1.

SpringBoot监控API请求耗时的6中解决解决方案

《SpringBoot监控API请求耗时的6中解决解决方案》本文介绍SpringBoot中记录API请求耗时的6种方案,包括手动埋点、AOP切面、拦截器、Filter、事件监听、Micrometer+... 目录1. 简介2.实战案例2.1 手动记录2.2 自定义AOP记录2.3 拦截器技术2.4 使用Fi