cocos2d-基本概念(5)-Effects效果2011-01-31 博客园 Alexliu译Effects 效果Introduction 介绍Effects 是一些列特别的动作。相比于改变通常的属性,像透明度,位置,旋转,或者缩放而言,它们修改的一种新的属性,Grid(网格)属性。一个Grid 属性就好像一个矩阵,是一个网络的线,组成一系列的方块和矩阵。这些特别的动作把任何一个cocosNode 对象(层,场景,精灵等)变化成Grid,你可以通过它们的顶点来改变它们。有两种不同的Grid:tiled 和 non-tiled网格,不同的是tiled网格是通过各自tiled组成,而non-tiled是通过顶点组成的。

一个Grid有2个维度,行和列。但是任何一个vertex都有3个维度,xyz。所以你可以建立一个2d或者是3d的效果,不同的是通过tiled-grid-3d 或者是grid-3d。你可以通过提高增加grid的大小来提高效果的质量,但是效果的速度将会降低。一个(16,12)大小的grid将会运行的非常快,但是并不会看起来非常的好。(32,24)的将会看起来非常棒,但是在iphone1代中,运行起来不会太快。How they work 如何工作Each frame the screen is rendered into a texture (FBO). This texture is transformed into a vertex array and this vertex array (the grid!) is transformed by the grid effects. Finally the vertex array is rendered into the screen.任何一个屏幕的Frame都会改称成一个Texture(FBO),这个纹理会转换城一个顶点array,这个顶点坐标array是通过grid的效果转换来的。最后,这个顶点数组被显示到屏幕上。For more information about the internals refer to:TiledGrid3D and TiledGrid3DAction for tiled gridsGrid3D and Grid3DAction for non-tiled gridsFor example, if you have an scene or layer that renders this image: