Skip to content

Commit

Permalink
brief description of sprite type
Browse files Browse the repository at this point in the history
  • Loading branch information
rainfiel committed Dec 17, 2015
1 parent 47016ef commit f2748a6
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions doc/apicn.md
Expand Up @@ -297,6 +297,47 @@ sprite 用 lua 表的形式描述在资源文件中。资源文件通常于开

详细文档待补充。

### sprite 类型
> Picture

最基础的渲染单位之一,表示一个四边形从贴图到屏幕的映射关系。一个Picture结构可以是多个四边形的组合,渲染顺序与组合排列顺序一致。示例如下:

```Lua
{
type = "picture",
id = 2,
{ tex = 1 ,
src = { 178, 112, 144, 112, 144, 137, 178, 137 },
screen = { -388, -652, -384, 452, 416, 452, 412, -652} },
}
```
src 字段 8 个整数表示的是 4 组贴图坐标,以像素为单位。screen 字段的 8 个整数则表示对应的屏幕坐标,是以屏幕像素为单位,但放大了 16 倍。你也可以认为这是一种定点数表达。
> Polygon

Picture,对应多边形。

> Animation

一个 animation 是由若干 component 构成的。每个 component 可以用 id 引用其它的 sprite 对象(不限于静态图片组还是另一组动画),但你得保证不能成环。

animation 可以又多组动画序列,每组是一个 action 。当然你也可以只有一组默认动画组,这样不需要给 action 起名字。当有多组的时候,需要在描述数据里加上 action 字段,给一个字符串名字。

一组动画序列(action)是由若干 frame 组成的。每个 frame 可以由这个 animation 中定义的 component 任意组合。我们可以在资源文件中描述组合关系,如果简单引用一个 componenent ,就写上其编号( base 0 )。也可以加上一个变换矩阵,以及两个颜色值( coloradditive )。渲染的时候引擎会把这个 component 的颜色乘上 color 加上 additive

> Label

用于显示文本内容的控件,定义字体的大小,颜色,描边,锚点等信息。

> Panel

用于定义一个剪切区(scissor

> Anchor

可以认为是Animation中一种特殊类型的component,当一个component没有指定id只有name字段的时候会被当作是一个Anchor。默认情况下Anchor可以作为一个挂点用于mount其他对象,另外在将Anchor对象设为visible状态后,它将在每次渲染之后记录下自己相对于根节点的matrix,可以通过world_matrix方法或world_pos方法获得这个节点的坐标等信息。



## <span id="particle">particle</span>

ejoy2d粒子发射器的描述文件见[examples/asset/particle_particle_config.lua](https://github.com/cloudwu/ejoy2d/blob/master/examples/asset/particle_particle_config.lua)。该文件基于[Particle Designer](http://particledesigner.71squared.com/)的输出而生成,即可以使用Particle Designer来编辑粒子系统。
Expand Down

0 comments on commit f2748a6

Please sign in to comment.