One of the cool features that Cocos2d-x has to offer is the power of transitions within two different scene. Transitions are effects such as: wipe, fade, zoom, and split. You can use transitions to switch between Cocos2d-x Scene objects. Sceneclass is derived from CocosNode and it is similar to Layer. You can add other CocosNode, such as Layer(s) and Sprite(s) into a Scene.
Some transitions has custom parameter(s); for example, FadeTransition has the fade color as extra parameter.
static CCTransitionFade* create(float duration,CCScene* scene, const ccColor3B& color);
To enable a transition, it is not much more difficult. Here we have an small example:
The term particle system refers to a computer graphics technique that uses a large number of very small sprites or other graphic objects to simulate certain kinds of “fuzzy” phenomena, which are otherwise very hard to reproduce with conventional rendering techniques - usually highly chaotic systems, natural phenomena, and/or processes caused by chemical reactions.
- Spinning particles: particles can rotate around its axis. CCParticleSystemPoint ignores this property.
- Particles can have any size. In CCParticleSystemPoint if the size is bigger than 64, it will be treated as 64.
- The whole system can be scaled using the scale property.
Because of CCParticleSystemPoint does not support CCParticleBatchNode. As the result, CCParticleSystemPoint has been removed from cocos2d-x particle system.
A CCParticleBatchNode can reference one and only one texture (one image file, one texture atlas). Only the CCParticleSystems that are contained in that texture can be added to the CCSpriteBatchNode. All CCParticleSystems added to a CCSpriteBatchNode are drawn in one OpenGL ES draw call. If the CCParticleSystems are not added to a CCParticleBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient.
Gravity Mode lets particles fly toward or away from a center point. Its strength is that it allows very dynamic, organic effects. You can set gravity mode with this line:
- gravity (a CGPoint). The gravity of the particle system
- speed (a float). The speed at which the particles are emitted
- speedVar (a float). The speed variance.
- tangencialAccel (a float). The tangential acceleration of the particles.
- tangencialAccelVar (a float). The tangential acceleration variance.
- radialAccel (a float). The radial acceleration of the particles.
- radialAccelVar (a float). The radial acceleration variance.
重力(CGPoint)。粒子系统的重力。
速度(float)。粒子发射时的速度。
速度变量speedVar(float)。速度的变异数。
tangencialAccel(float)。粒子的正切加速度。
tangencialAccelVar(float)。粒子正切加速度的差异数。
radialAccel(float)。粒子的径向加速度。
radialAccelVar(float)。粒子径向加速度的差异数。
半径模式 Radius Mode
Radius Mode causes particles to rotate in a circle. It also allows you to create spiral effects with particles either rushing inward or orating outward. You set radius mode with this line:
- startRadius (a float). The starting radius of the particles
- startRadiusVar (a float). The starting radius variance
- endRadius (a float). The ending radius of the particles.
- endRadiusVar (a float). The ending radius variance
- rotatePerSecond (a float). Number of degress to rotate a particle around the source pos per second.
- rotatePerSecondVar (a float). Number of degrees variance.
startRadius(float)。粒子开始时的半径。
startRadiusVar(float)。粒子开始时的半径变异数。
endRadius(float)。粒子结束时的半径。
endRadiusVar(float)。结束时粒子的半径变异数。
rotatePerSecond(float)。粒子围绕原点每秒旋转的度数。
rotatePerSecondVar(float)。度数的变异数。
各模式下的通用属性
粒子通用属性:
- startSize: Start size of the particles in pixels
- startSizeVar
- endSize: Use kCCParticleStartSizeEqualToEndSize if you want that the start size == end size.
- endSizeVar
- startColor (a ccColor4F)
- startColorVar (a ccColor4F)
- endColor (a ccColor4F)
- endColorVar (a ccColor4F)
- startSpin. Only used in CCParticleSystemQuad
- startSpinVar. Only used in CCParticleSystemQuad
- endSpin. Only used in CCParticleSystemQuad
- endSpinVar. Only used in CCParticleSystemQuad
- life: time to live of the particles in seconds
- lifeVar:
- angle: (a float). Starting degrees of the particle
- angleVar
- positon: (a CGPoint)
- posVar
- centerOfGravity (a CGPoint)
- emissionRate (a float). How many particle are emitted per second
- duration (a float). How many seconds does the particle system (different than the life property) lives. Use kCCParticleDurationInfinity for infity.
- blendFunc (a ccBlendFunc). The OpenGL blending function used for the system
- positionType (a tCCPositionType). Use kCCPositionTypeFree (default one) for moving particles freely. Or use kCCPositionTypeGrouped to move them in a group.
- texture (a CCTexture2D). The texture used for the particles
Effects are a special kind of action. Instead of modifying normal properties like opacity, position, rotation, or scale, they modify a new kind of property: the grid property.
There are 2 kind of grids: tiled grids and non-tiled grids. The difference is that the tiled grid is composed of individual tiles while the non-tiled grid is composed of vertices.
Liquid, like any other grid action, receives the grid parameter. You can adjust the quality of the effect by increasing the size of the grid. But it also implies less FPS.
The Effects are IntervalAction actions so you can treat them like any other action. eg:
You can creat animations using “sprite sheets” which is quick and easy. Until you realize your game needs lots of animations and the memory consumption goes way up, together with the time required to load all the data. Also, to limit the size, you need to limit yourself to a low FPS for the animation, which also means the animation doesn’t look as smooth as you’d like. This is where skeletal animation comes in.
Skeletal animation is a technique in cocos2d-x animation in which a character is represented in two parts: a surface representation used to draw the character (called skin or mesh) and a hierarchical set of interconnected bones (called the skeleton or rig) used to animate (pose and keyframe) the mesh.
Cocos2d-x provides a way to have 2d skeletal animations in your applications. The process of skeletal animation may be a bit complicated to setup, but using them afterwards is easy, and there are some tools to simplify the process.
When using skeletal animation, the animation is composed of several bones which are connected to one another. Affecting a bone also affects all of its children. By composing different transformations on each bone, you obtain different poses for the skeleton.
Now, if you define keyframes with certain transformations for a point in time for each of the bones in the skeleton, you can interpolate between the keyframes to obtain a smooth transition and thus animate the skeleton.
In the attached code, I used a class named Transformation, which contains data about 2D transformations, like translation, rotation and scale. Then, a Keyframe is defined by a frame number and one such Transformation. A collection of Keyframes defines a KeyframeAnimation. Finally, a SkeletonAnimation is a collection of KeyframeAnimations, one for each bone in the skeleton.
Separately, you use a Skeleton, which keeps a list of Joints that define the hierarchy of bones in the skeleton. Different from “sprite sheets”,each bone is then assigned a certain texture, like the ones below:
So far as we know, [CocosBuilder](http://cocosbuilder.com/) is a great, free (MIT license) tool for creating skeleton animations.
CocosBuilder is built for Cocos2d’s Javascript bindings, which means that your code, animations, and interfaces will run unmodified in Cocos2d-x.
A tutorial for cocos2d-iphone can be found at the [Zynga Engineering blog](http://code.zynga.com/2012/10/creating-a-game-with-cocosbuilder/)
You can use CocosBuilder for creating character animations, animating complete scenes or just about any animation you can imagine. The animation editor has full support for multiple resolutions, easing between keyframes, boned animations and multiple timelines to name a few of the features.
h3.The Basics
In the bottom of the main window you can find the timeline. You use the timeline to create your animations.
By default your ccb-file has a single timeline that is 10 seconds long. CocosBuilder edits animations at a frame rate of 30 frames per second, but when you play back the animation in your app it will use whatever you have set cocos2d to use (the default in cocos2d is 60 fps). The current time is displayed in the top right corner, and has the format minute:second:frame. The blue vertical line also shows the current time. Click the time display to change the duration of the current timeline.
Animations in CocosBuilder are keyframe based. You can add keyframes to different properties of a node and CocosBuilder will automatically interpolate between the keyframes, optionally with different types of easing.
To add a keyframe, first expand the view of the node by clicking the triangle to the right of the name of the node. This will reveal all the animatable properties of the node. What can be animated varies slightly depending on what type of node you have selected. Once the properties are visible you can click the property in the timeline with the option key held down. This will create a new keyframe at the time of the click. Alternatively, you can create a new keyframe at the time of the time marker by selecting a node then choosing Insert Keyframe in the Animation menu.
Keyframes are automatically added at the current time if you transform a node in the canvas area, given that the transformed property already has one or more keyframes in the timeline.
You edit a specific keyframe of a node by moving the time marker to the time of the keyframe and selecting the node. You can focus on a keyframe by double clicking it (which will select the node and move the time marker).
You can select keyframes and move them together by dragging a selection box around them. You can also copy and paste keyframes between nodes. Make sure you only have one selected node when pasting the keyframes. The keyframes will be pasted starting at the time of the time marker.
If you have selected a set of keyframes it is possible to reverse the order of them by selecting Reverse Selected Keyframes in the Animation menu. Use the Stretch Selected Keyframes… option to speed up or slow down an animation by a scaling factor.
If you have an animation created by sprite frames it can be tedious to move each individual frame to the timeline. CocosBuilder simplifies this process by automatically importing a sequence of images. Select the frames that you want to import in the left hand project view, then select a CCSprite in the timeline. Now choose Create Frames from Selected Resources in the Animation menu. The frames will automatically be created at the start of the marker. If you need to slow down the animation, select the newly created keyframes and use the Stretch Selected Keyframes… command.
如果你通过sprite frame帧组创建动画,需要冗长的时间来将每个独立的帧移至时间轴上。CocosBuilder通过自动导入图像序列简化了这一过程。选择你想要导入到左边项目视图的帧,然后选择时间轴上的一个CCSprite。现在选择Animation菜单中的Create Frames from Selected Resources.这些帧会在时间标志线开始的地方添加。如果你需要放慢动画,选择新创建的关键帧组,并使用Stretch Selected Keyframes…命令。
应用渐变
CocosBuilder offers a carefully selected subset of the easings provided by cocos2d. To apply an easing right click between two keyframes and select the type of easing that you want to apply.
Some of the easings have additional options, after the easing has been applied you can right click again and select Easing Setting… from the popup menu.
A very powerful feature of CocosBuilder’s animation editor is the ability to have multiple timelines in a single file. You can name the different sequences and play them back from your code by using their name. It’s even possible to smoothly transition between the different timelines.
To select, add or edit your timelines use the timeline popup menu:
In the edit timelines dialog you can get an overview of your timelines, rename them, add new ones and (optionally) set one of the timelines to automatically start playback directly when the ccbi-file is loaded by your app.
Properties in timelines that do not have keyframes set share their values across timelines. E.g. if you move one node in one timeline it will be moved in all timelines as long as they do not have a keyframe set for the position property. I can sometimes be useful to add a single keyframe to a property just to override the shared value for a specific timeline.
To programmatically control the animations you create with CocosBuilder you will need to retrieve theCCBAnimationManager. The animation manager will be assigned to the nodes userObject when the ccbi-file is loaded.
The action manager will be returned as an autoreleased object. To play back a specific timeline call therunAnimationsForSequenceNamed: method. If a timeline is currently playing it will be immediately stopped when calling this method.
Optionally, you can use a tween duration to smoothly transition to the new timeline. Where possible linear interpolations will be used for the transition.
It is also possible to receive a callback whenever a timeline has finished playing. You will receive these callbacks even if another timeline is chained in sequence. Use the CCBAnimationManagerDelegate to receive the callbacks.
Thank you taking the time to read through the tutorial and happy coding!If you have other tools for skeleton animation,please let us known or post to this wiki.
Scheduler is responsible for triggering the scheduled callbacks.
调度器负责触发调度回调.
两种不同类型的回调 (selectors):
update selector: the ‘update’ selector will be called every frame. You can customize the priority.
custom selector: A custom selector will be called every frame, or with a custom interval of time.
The ‘custom selectors’ should be avoided when possible. It is faster, and consumes less memory to use the ‘update selector’.
The Cocos2D Scheduler provides your game with timed events and calls. You should not use NSTimer. Instead use CCScheduler class.
The reasons as follow:
CCNode objects know how to schedule and unschedule events,and using the Cocos2D Scheduler has several distinct advantages over just using NSTimer.
- CCNode objects know how to schedule and unschedule events,and using the Cocos2D Scheduler has several distinct advantages over just using NSTimer.
- The scheduler calls get deactivated whenever the CCNode is no longer visible or is removed from the scene.
- The scheduler calls are also deactivated when Cocos2D is paused and are rescheduled when Cocos2D is resumed.
- The scheduler delivers a interval time of the milliseconds that have passed since the last call.This interval time is useful in Physics engines.
- Using scheduler with this->scheduleUpdate(); call ensures that your update function will be called before each frame needs to be rendered.
Accordingly,CCScheduler can save you a lot of time over NSTimer and let you focus on the mechanics of your game.
Last updated by Iven Yang at Updated about 1 month ago.
Animations
Manual Animation
Sprite Sheet Animation
Creating from .png and .plist file
File animation
Skeleton Animation
Comment
Frame Animation(帧动画)
You can create an animation from a series of image file, like this:
你可以通过多张图片文件来创建一个动画,比如:
123456789101112131415
CCAnimation *animation = CCAnimation::create();
// load image file from local file system to CCSpriteFrame, then add into CCAnimation
for (int i = 1; i < 15; i++)
{
char szImageFileName[128] = {0};
sprintf(szImageFileName, "Images/grossini_dance_%02d.png", i);
animation->addSpriteFrameWithFileName(szImageFileName);
}
animation->setDelayPerUnit(2.8f / 14.0f); // This animation contains 14 frames, will continuous 2.8 seconds.
animation->setRestoreOriginalFrame(true); // Return to the 1st frame after the 14th frame is played.
CCAnimate *action = CCAnimate::create(animation);
sprite->runAction(action); // run action on sprite object
Note that CCAnimation is composed by sprite frames, delay time per frame, durations etc, it’s a pack of “data”. While CCAnimate is an action, which is created base on CCAnimation object.
Although manual animation is very easy to understand, it’s rarely used in real game projects. Instead, sprite sheet animation is the common solution of 2D animations.
In OpenGL ES 1.1 period, sprite sheets was widely used for these benefits:
Reduce times of file I/O. Loading a big sprite sheet file is faster than loading lots of small files.
Reduce the memory consumption. OpenGL ES 1.1 can only use power-of-two sized textures (that is a width or height of 2,4,864,128,256,512,1024,…). In other words, OpenGL ES 1.1 allocates power-of-two sized memory for each texture even if this texture has smaller width and height. So using packed sprite sheet image will reduce the fragments of memory.
Reduce the draw calls to OpenGL ES draw method and speed up rendering.
在OpenGL ES 1.1时代,sprite sheets被广泛使用是得益于:
减少文件I/O时间.加载一个大的sprite sheet文件比加载多个小文件要快得多.
减少内存消耗.OpenGL ES 1.1仅可用2幂次方大小的texture(通常为 2,4,864,128,256,512,1024,…的宽高).换言之,如果宽高比较小的话,OpenGL ES 1.1甚至为每个texture分配2幂次方大小内存.所以使用成组的 sprite sheet图片会减少内存碎片.
减少 OpenGL ES 调用方法绘制,加速渲染.
Cocos2d-x v2.0 upgraded to OpenGL ES 2.0 based. OpenGL ES 2.0 doesn’t allocate power-of-two memory block for textures anymore, but the benefit of reducing file I/O times and draw calls are still working.
Cocos2d-x v2.0已更新,是基于OpenGL ES 2.0的.OpenGL ES 2.0不再为textures分配2的幂次方内存块,但减少文件系统I/O和绘图调用时间的好处仍然是有效的.
Then how about the animation? As we can see, sprite sheet has no MUST-BE relationship with animations. But considering to these benefits above, sprite sheet animations are efficient. There’re different ways to create sprite sheet animations in cocos2d.
A CCSpriteBatchNode object contains the actual image texture of all the sprite frames. You must add it to a scene, even though it won’t draw anything itself; it just needs to be there so that it is part of the rendering pipeline. For example:
1CCSpriteBatchNode* spritebatch = CCSpriteBatchNode::create(“animations/grossini.png”);
Next, you need to use the CCSpriteFrameCache singleton to keep track how frame names correspond to frame bounds – that is, what rectangular area of the sprite sheet. Example:
Once your sprite sheet and frames are loaded, and the sprite sheet has been added to the scene, you can create sprites that use these frames by using the “createWithSpriteFrameName” method, and adding it as a child of the sprite sheet:
createWithSpriteFrameName method will find the corresponding coordinates and rectangle from grossini.plist, then “clip” the texture grossini.png to a sprite frame.
Now we need to create a CCArray object and add all frames of the animation to it. In the case of this animation, we know all 14 frames have the same size, so we can use a nested loop to iterate through them all, and break the loop when we finish adding the 14th frame.
Finally, we need to create a CCAnimate action instance which we can run on the CCSprite. Below, we also wrap the CCAnimate action in a CCRepeatForever action that does what you would expect: repeats the animation forever,like so:
CCAnimationCache can load a xml/plist file which well describes the batch node, sprite frame names and their rectangles. The interfaces are much easier to use.
CCAnimationCache*cache=CCAnimationCache::sharedAnimationCache();// "caches" are always singletons in cocos2dcache->addAnimationsWithFile("animations/animations-2.plist");CCAnimationanimation=cache->animationByName("dance_1");// I apologize for this method name, it should be getAnimationByName(..) in future versionsCCAnimateanimate=CCAnimate::create(animation);// Don't confused between CCAnimation and CCAnimate :)sprite->runAction(animate);
Actions are like orders given to any 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 actions’ visual effects. And cocos2d-x/samples/Cpp/TestCpp/Classes/ActionsTest, ActionsEaseTest are good sample codes for the usage.
你可以运行TestCpp -> Actions Test 来查看动作的可视化效果。cocos2d-x/samples/Cpp/TestCpp/Classes/ActionsTest, ActionsEaseTest中的用法是非常好的代码示例。
例如:
12
// Move a sprite 50 pixels to the right, and 10 pixels to the top over 2 seconds.
CCActionInterval* actionBy = CCMoveBy::create(2, ccp(50,10));
The CCIntervalAction actions have some interesting properties:
They can be accelerated using the time-altered actions
CCIntervalAction动作有一些有意思的属性:
使用变速动作可以对CCIntervalAction动作进行加速等,变速动作有:
CCEaseIn
CCEaseOut
CCEaseInOut
CCSpeed
Etc. (See the ActionsEaseTest.cpp example for more info)
(更多信息,详见ActionsEaseTest.cpp实例)
You can pause/resume all actions by using the CCActionManager:
You probably have known “Cartesian Coordinate System” from school where it’s heavily used in geometry lessons. If you have forgotten, these image will remind you quickly:
There’re 3 types of coordinate system that you will meet in mobile games development.
在移动游戏开发过程中,你可能会遇到三种类型的坐标系:
#### UI Coordinate System·
UI坐标系
In common UI Coordinates on iOS/Android/Windows SDK:
- The origin (x=0, y=0) is at the top-left corner.
- X axis starts at the left side of the screen and increase to the right;
- Y coordinates start at the top of the screen and increase downward,
We only use x-axis & y-axis in 2D world. So in your cocos2d games:
- The origin (x=0, y=0) is in the bottom-left corner of screen, which means the screen is in the first quartile of right-handed cartesian coordinate system,
- X axis starts at the left side of the screen and increase to the right;
- Y axis starts at the bottom of the screen and increase upwards.
在2D世界中,我们仅会使用x轴和y轴。所以在你的cocos2d游戏中:
起点坐标(x=0, y=0)位于右下角,这意味着屏幕位于右手笛卡尔坐标系的第一象限
X轴从屏幕最左边开始,由左向右渐增
Y轴坐标从屏幕最下方开始,由下向上渐增
And here’s a picture that helps illustrate Cocos2d-x Coordinates a bit better:
下面这张图片有助于更好的阐述Cocos2d-x坐标:
Note that it’s different from common UI coordinate systems and DirectX coordinate systems.
一定要注意:通用UI坐标系和DirectX坐标系是不一样的。
Parent and Childrens
Every class derived from CCNode (Ultimate cocos2d-x class) will have a anchorPoint property.
When determining where to draw the object (sprite, layer, whatever), cocos2d-x will combine both properties position and anchorPoint. Also, when rotating an object, cocos2d-x will rotate it around its anchorPoint.
We create a sprite as a gray parent and another sprite as blue child.Set parent’s position to ccp(100,100),child’s anchor point in the center of circle .
VisibleSize returns visible size of the OpenGL view in points.The value is equal to getWinSize if don’t invoke CCEGLView::setDesignResolutionSize().
getVisibleOrigin returns visible origin of the OpenGL view in points. Please refer to [Multi resolution support](Multi resolution support) for more details
convertToNodeSpace will be used in, for example, tile-based games, where you have a big map. convertToNodeSpace will convert your openGL touch co-ordinates to the co-ordinates of the .tmx map or anything similar.
Example:
The following picture shows that we have node1 with anchor point (0,0) and node2 with anchor point (1,1).
We invoke CCPoint point = node1->convertToNodeSpace(node2->getPosition()); convert node2’s SCREEN coords to node1’s local.As the result,node2 with the position of (-25,-60).
我们调用CCPoint point = node1->convertToNodeSpace(node2->getPosition()); 相对node1的本地位置转换node2的屏幕坐标。结果node2的位置是(-25,-60).
convertToWorldSpace:
convertToWorldSpace(const CCPoint& nodePoint) converts on-node coords to SCREEN coordinates.convertToWorldSpace will always return SCREEN position of our sprite, might be very useful if you want to capture taps on your sprite but need to move/scale your layer
Example:
CCPoint point = node1->convertToWorldSpace(node2->getPosition());
the above code will convert the node2‘s coordinates to the coordinates on the screen.
For example if the position of node2 is (0, 0) which will be the bottom left corner of the node1, but not necessarily on the screen. This will convert (0, 0) of the node2 to the position of the screen(in this case is (15,20)). The result shows in the following picture:
convertToWorldSpaceAR will return the position relatevely to anchor point: so if our scene - root layer has Anchor Point of ccp(0.5f, 0.5f) - default, convertToWorldSpaceAR should return position relatively to screen center.
convertToNodeSpaceAR - the same logic as for .convertToWorldSpaceAR
A scene (implemented with the CCScene object) is more or less an independent piece of the app workflow. Some people may call them “screens” or “stages”. Your app can have many scenes, but only one of them is active at a given time.
For example, you could have a game with the following scenes: Intro, Menu, Level 1, Cutscene 1, Level 2, Winning cutscene, losing cutscene, High scores screen.
You can define every one of these scenes more or less as separate apps; there is a bit of glue between them containing the logic for connecting scenes (the intro goes to the menu when interrupted or finishing, Level 1 can lead you to the cutscene 1 if finished or to the losing cutscene if you lose, etc.).
A cocos2d CCScene is composed of one or more layers (implemented with the CCLayer object), all of them piled up. Layers give the scene an appearance and behavior; the normal use case is to just make instances of Scene with the layers that you want.
There is also a family of CCScene classes called transitions (implemented with the CCTransitionScene object) which allow you to make transitions between two scenes (fade out/in, slide from a side, etc).
- See more at: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Director_Scene_Layer_and_Sprite#sthash.jF0fVw56.dpuf
Director·导演类
The CCDirector is the component which takes care of going back and forth between scenes.
CCDirector是控制场景之间进出的组件。
The CCDirector is a shared (singleton) object. It knows which scene is currently active, and it handles a stack of scenes to allow things like “scene calls” (pausing a Scene and putting it on hold while another enters, and then returning to the original). The CCDirector is the one who will actually change the CCScene, after a CCLayer has asked for push, replacement or end of the current scene.
The CCDirector is also responsible for initializing OpenGL ES.
CCDirector也可以通过初始化OpenGL ES来响应。
- See more at: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Director_Scene_Layer_and_Sprite#sthash.jF0fVw56.dpuf
Layers·层
A CCLayer has a size of the whole drawable area, and knows how to draw itself. It can be semi transparent (having holes and/or partial transparency in some/all places), allowing to see other layers behind it. Layers are the ones defining appearance and behavior, so most of your programming time will be spent coding CCLayer subclasses that do what you need.
The CCLayer is where you define event handlers. Events are propagated to layers (from front to back) until some layer catches the event and accepts it.
Although some serious apps will require you to define custom CCLayer classes, cocos2d provides a library of useful predefined layers (a simple menu layer: CCMenu, a color layer: CCColorLayer, a multiplexor between other layers: CCMultiplexLayer, and more ).
- See more at: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Director_Scene_Layer_and_Sprite#sthash.jF0fVw56.dpuf
Sprites·精灵
A cocos2d’ sprite is like any other computer sprite. It is a 2D image that can be moved, rotated, scaled, animated, etc.
cocos2d的精灵看起来和其他计算机精灵一样。它是2D图像,可以移动,旋转,缩放,动画,等等
Sprites (implemented using the CCSprite class) can have other sprites as children. When a parent is transformed, all its children are transformed as well.