1.Sprite

对sprite设置anchor point,对应的位置

// DEFAULT anchor point for all Sprites
mySprite->setAnchorPoint(0.5, 0.5); // bottom left
mySprite->setAnchorPoint(, ); // top left
mySprite->setAnchorPoint(, ); // bottom right
mySprite->setAnchorPoint(, ); // top right
mySprite->setAnchorPoint(, );

2.Actions - By and To, what is the difference?

A By is relative to the current state of the Node. A To action is absolute, meaning it doesn't take into account the current state of the Node

auto mySprite = Sprite::create("mysprite.png");
mySprite->setPosition(Vec2(, )); // MoveBy - lets move the sprite by 500 on the x axis over 2 seconds
// MoveBy is relative - since x = 200 + 200 move = x is now 400 after the move
auto moveBy = MoveBy::create(, Vec2(, mySprite->getPositionY())); // MoveTo - lets move the new sprite to 300 x 256 over 2 seconds
// MoveTo is absolute - The sprite gets moved to 300 x 256 regardless of
// where it is located now.
auto moveTo = MoveTo::create(, Vec2(, mySprite->getPositionY())); auto seq = Sequence::create(moveBy, delay, moveTo, nullptr); mySprite->runAction(seq);

2.1 Move

auto mySprite = Sprite::create("mysprite.png");

// Move a sprite to a specific location over 2 seconds.
auto moveTo = MoveTo::create(, Vec2(, )); mySprite->runAction(moveTo); // Move a sprite 50 pixels to the right, and 0 pixels to the top over 2 seconds.
auto moveBy = MoveBy::create(, Vec2(, )); mySprite->runAction(moveBy);

2.2 Rotate

auto mySprite = Sprite::create("mysprite.png");

// Rotates a Node to the specific angle over 2 seconds
auto rotateTo = RotateTo::create(2.0f, 40.0f);
mySprite->runAction(rotateTo); // Rotates a Node clockwise by 40 degree over 2 seconds
auto rotateBy = RotateBy::create(2.0f, 40.0f);
mySprite->runAction(rotateBy);

2.3 Scale

auto mySprite = Sprite::create("mysprite.png");

// Scale uniformly by 3x over 2 seconds
auto scaleBy = ScaleBy::create(2.0f, 3.0f);
mySprite->runAction(scaleBy); // Scale X by 5 and Y by 3x over 2 seconds
auto scaleBy = ScaleBy::create(2.0f, 3.0f, 3.0f);
mySprite->runAction(scaleBy); // Scale to uniformly to 3x over 2 seconds
auto scaleTo = ScaleTo::create(2.0f, 3.0f);
mySprite->runAction(scaleTo); // Scale X to 5 and Y to 3x over 2 seconds
auto scaleTo = ScaleTo::create(2.0f, 3.0f, 3.0f);
mySprite->runAction(scaleTo);

2.4 Fade In/Out

auto mySprite = Sprite::create("mysprite.png");

// fades in the sprite in 1 seconds
auto fadeIn = FadeIn::create(1.0f);
mySprite->runAction(fadeIn); // fades out the sprite in 2 seconds
auto fadeOut = FadeOut::create(2.0f);
mySprite->runAction(fadeOut);

2.5 Tint

auto mySprite = Sprite::create("mysprite.png");

// Tints a node to the specified RGB values
auto tintTo = TintTo::create(2.0f, 120.0f, 232.0f, 254.0f);
mySprite->runAction(tintTo); // Tints a node BY the delta of the specified RGB values.
auto tintBy = TintBy::create(2.0f, 120.0f, 232.0f, 254.0f);
mySprite->runAction(tintBy);

cocos2dx day 2 - Sprites的更多相关文章

  1. cocos2D-X Doc

    { //https://docs.cocos2d-x.org/api-ref/index.html //https://docs.cocos.com/cocos2d-x/manual/zh/sprit ...

  2. cocos2d-x项目101次相遇: Scenes , Director, Layers, Sprites

    cocos2d-x 101次相遇 / 文件夹  1   安装和环境搭建 -xcode  2   Scenes , Director, Layers, Sprites 3   建立图片菜单  4   在 ...

  3. quick cocos2dx lua 内存释放

    前言 对于内存的优化,网上有很多例子和教程.总体来说,就那么几种解决方案,在最后我会简单提下,这里先说下在quick中,对于图片的处理. 1.查看内存调试信息 对于quick框架的了解,我们可以参考\ ...

  4. [Cocos2d-x For WP8]基础知识

    一.重要概念 导演(CCDirector) 在cocos2d-x引擎中,CCDirector类是整个游戏的组织和控制核心,游戏的运行规则,游戏内的CCScene(场景).布景(CCLayer).角色( ...

  5. cocos2d-x 纹理深入研究 第二部分

    转自:http://blog.csdn.net/qq51931373/article/details/9152227 1.纹理控制. 看此代码: CCSprite *pSprite = CCSprit ...

  6. 【Cocos2d入门教程二】Cocos2d-x基础篇

    上一章已经学习了环境的搭建.这一章对基础概念进行掌握.内容大概有: 1.导演 2.场景 3.节点 4.层 4.精灵 1.导演(Director) 导演存在的主要作用: a.环境设定(帧率 初始化ope ...

  7. cocos2d-x c++和object-c内存管理比较

    转自:http://www.2cto.com/kf/201307/227142.html 既然选择了C++作为游戏开发的语言, 手动的管理内存是难以避免的, 而Cocos2d-x的仿Objctive- ...

  8. cocos2d-x 纹理深入研究

    转自:http://blog.csdn.net/qq51931373/article/details/9152227 1.纹理控制. 看此代码: CCSprite *pSprite = CCSprit ...

  9. 一、cocos2dx概念简介

    cocos2dx概念介绍 1)scene,继承自CCScene 场景,一个游戏运行期间的显示界面,一个应用里面可以有多个场景,但是每次只能有一个是激活状态,也可以理解为一次只能显示一个界面. 例如,你 ...

随机推荐

  1. Javascript 自动计算生日

    首先调用方法需要注意 //inner_page为外围大层,确保时间可以实时修改  $(".inner_page").mouseover(function() {        va ...

  2. 出现( linker command failed with exit code 1)错误总结 (转)

    这种问题,通常出现在添加第三方库文件或者多人开发时. 这种问题一般是找不到文件而导致的链接错误. 我们可以从如下几个方面着手排查. 1.以如下错误为例,如果是多人开发,你同步完成后发现出现如下的错误. ...

  3. WKWebView比UIWebView优越性

    1.在使用两者的过程中发现前者比后者节省内存一倍多,WKWebView 是苹果在 iOS 8 中引入的新组件,目的是给出一个新的高性能的 Web View 解决方案,摆脱过去 UIWebView 的老 ...

  4. 数论 UVA 10791

    这道题目是关于满足同意最小公倍数的所有数对中两数之和的最小值. 题目大意是给你一个数n,要求你求出在所有以n为最小公倍数的数对中两数之和的最小值. 方法:将n进行质因数分解,再将所有分解出的质因子加起 ...

  5. markdown 语法测试

    understanding the linux kernel 绪论 linux支持.硬件依赖.版本 基于微内核的方法 支持内核线程 多线程应用支持 抢占式内核 硬件依耐性 file descripto ...

  6. HTML5 地理位置定位(HTML5 Geolocation)原理及应用

    地理位置(Geolocation)是 HTML5 的重要特性之一,提供了确定用户位置的功能,借助这个特性能够开发基于位置信息的应用.今天这篇文章向大家介绍一下 HTML5 地理位置定位的基本原理及各个 ...

  7. linux命令之三

    0102 文档查阅指令 cat tac nl 简单查阅,-n  可显示行 more, less less is more 查询大文件,可分页. head tail 从头尾看.-n 限制行数. taif ...

  8. pptp 之 静态路由

    上网的人总是离不开VPN,你们都懂得.以前总是买付费的VPN,慢的要死,还不便宜.于是就自己买了个国外VPS 搭建了个PPTP,超级简单.网上教程大把大把的. VPN是全局代理,上google啥的没毛 ...

  9. 初学HTML5、初入前端

    学习HTML5是一个漫长的过程,当中会遇到很多技术与心态上的变化.刚开始学习,我们不能发力过猛,需要一个相对稳定的状态去面对.多关注一些自己感兴趣的网站和技术知识,建立自己的信心与好奇心,为以后的学习 ...

  10. 关于VR边纹理材质的渲染

    前段时间经常渲染白模线框的图,写了这个脚本方便工作,后来又加了中英文适配,今天贴上来. fn YY_edgestex = ( vr = renderers.current case of ( (vr材 ...