cocos study notes-Sprite
来源:互联网 发布:淘宝围巾店那个品牌好 编辑:程序博客网 时间:2024/06/11 13:48
cocos study notes-Sprite
Reference: [jellythink](“http://www.jellythink.com/archives/742“)
1.Sprite class
Sprite
is a 2D picture object,which can be defined by using a picture or part of picture.A Sprite
can move, rotate, play action and so on. It consist of Texture
,Frame
,Animation
.
important:
We usually use Texture2D to load the picture, then use it to produce SpriteFrame
.After that , we add SpriteFrame
to the Animation
to produce action data.Finally, Animation
produces Animate
.Then Sprite
puts it into action.
2.Sprite
API:
//create an empty sprite and then use `setTexture` to set the texturestatic Sprite* create();//create a sprite with an imagestatic Sprite* create(const std::string& filename);//create a sprite with a Texture2D objectstatic Sprite* createWithTexture(Texture2D* texture);//create a sprite by using spriteframestatic Sprite* createWithSpriteFrame(SpriteFrame *spriteFrame);/*create a sprite by using a spriteframe,inside the programe, IDE will get `SpriteFrame` from `SpriteFrameCache` according to `SpriteFrameName` parameter */static Sprite* createWithSpriteFrameName(const std::string& spriteFrameName)
3.SpriteBatchNode
If we need to render many sprites,we can use SpriteBatchNode
to render them in one time to save spending,like this:
auto batchNode = SpriteBatchNode::create("CloseNormal.png", 1000);batchNode->setPosition(Point::ZERO);this->addChild(batchNode);for (int i = 0;i < 1000;i++){ int x = rand() % 960; int y = rand() % 640; auto testIcon = Sprite::createWithTexture(batchNode->getTexture()); testIcon->setPosition(ccp(x, y)); batchNode->addChild(testIcon);}
0 0
- cocos study notes-Sprite
- Cocos study notes-Menu
- cocos study notes-Scene
- study notes
- cocos创建Sprite
- MySql study notes [1]
- Portlet Study Notes (1)
- IBM Director study notes
- lucene study notes
- lucene study notes (2)
- Legacy Study notes(Servlet)
- C++ Study Notes
- System Architect Study notes
- flex study notes (2)
- scm515 study notes
- Java API Study Notes
- Webkit Timer study notes
- Webkit JNI study notes
- 跨域访问使用nat123映射到外网的url的问题
- 【java】【多线程】线程安全与线程非安全【1】
- 记录学习《0Day安全》路上遇到的问题解决方案 利用Ret2Libc挑战DEP
- URL使用
- hdu1896(优先队列)
- cocos study notes-Sprite
- 《谷歌和亚马逊如何做产品》读书笔记之十三:再度启航
- MVC项目发布到服务器之后遇到的HTTP错误 403.14-Forbidden解决办法
- Android 定时器方法详解
- python正则表达式
- 类名.class, class.forName(), getClass()区别
- linux_011之库函数write.c
- 异步编程——Promise
- 大神博客