博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Cocos2d-x::Actions
阅读量:6320 次
发布时间:2019-06-22

本文共 1904 字,大约阅读时间需要 6 分钟。

hot3.png

Actions are orders given to a CCNode object. These actions usually modify some of the object's attributes like position, rotation, scale, etc. If these attributes are modified during a period of time, they are CCIntervalAction actions, otherwise they are CCInstantAction actions. For example, the CCMoveBy action modifies the position property during a period of time, hence, it is a subclass of CCIntervalAction.

You can run TestCpp->Actions test to see the action's visual effects. And cocos2d-x/samples/Cpp/TestCpp/Classes/ActionsTest, ActionsEaseTest are good sample codes for the usage.

Example:

// Move a sprite 50 pixels to the right, and 10 pixels to the top over 2 seconds.2CCActionInterval*  actionBy = CCMoveBy::create(2, ccp(50,10));

The CCIntervalAction actions have some interesting properties: They can be accelerated using the time-altered actions

  • CCEaseIn
  • CCEaseOut
  • CCEaseInOut
  • CCSpeed Etc. (See the ActionsEaseTest.cpp example for more info)

You can pause/resume all actions by using the CCActionManager:

// Pause actionsCCDirector *director = CCDirector::sharedDirector();m_pPausedTargets = director->getActionManager()->pauseAllRunningActions();// resume actionsCCDirector *director = CCDirector::sharedDirector();director->getActionManager()->resumeTargets(m_pPausedTargets);

###Basic Actions Basic actions are the ones that modify basic properties like:

####Position

  • CCMoveBy
  • CCMoveTo
  • CCJumpBy
  • CCJumpTo
  • CCBezierBy
  • CCBezierTo
  • CCPlace

####Scale

  • CCScaleBy
  • CCScaleTo

####Rotation

  • CCRotateBy
  • CCRotateTo

####Visibility

  • CCShow

  • CCHide

  • CCBlink

  • CCToggleVisibility

  • Opacity

  • CCFadeIn

  • CCFadeOut

  • CCFadeTo

####Color

  • CCTintBy
  • CCTintTo

Example:

CCSprite *sprite = CCSprite::create("Images/grossini.png");sprite->setPosition(ccp(100, 100));addChild(sprite);CCMoveBy* act1 = CCMoveBy::create(0.5, ccp(100, 0));sprite->runAction(CCRepeat::create(act1, 1));

转载于:https://my.oschina.net/huangsz/blog/187038

你可能感兴趣的文章
Android项目启动时短暂的黑屏白屏处理
查看>>
使用TextInputLayout分分钟构造一个酷炫登录框架
查看>>
CocoaPods的安装失败方法
查看>>
Windows查看局域网内在线主机ip
查看>>
Docker的使用
查看>>
《java编程思想》学习笔记——内部类五
查看>>
Exchange 2010向外网发邮件的配置
查看>>
go语言函数例题
查看>>
订阅点评有奖,本人获奖了
查看>>
LeetCode - 69. x 的平方根
查看>>
安装包
查看>>
redis3.0.2 编译安装 (启动服务方式启动)
查看>>
642-832 GNS3 自搭建拓扑
查看>>
SEO的操作流程梗概
查看>>
linux yum命令
查看>>
职场中怎样评估系统架构师的成绩?
查看>>
(总结)Nginx/LVS/HAProxy负载均衡软件的优缺点详解
查看>>
MATLAB 图像的平滑和边缘检测
查看>>
孩子听不进道理怎么办?
查看>>
matplotlib之plot
查看>>