最近在学习Citrus Engine.
本帖是根据老外的一个帖子翻译过来的,没有全文翻译。原文查看
-----------------------------------------------------------------------------------------------
物理游戏经常会涉及到一些复杂的多边形,我们将借助PhysicsEditor来完成编辑这个多边形的过程
导入图片即可生成多边形模型
下面先看看例子的效果:点击查看效果
使用方法:按Tab键 会出现一个输入框,这时候输入:
set Box2D visible false
并按Enter 之后会出现原图,set Box2D visible true则反之。
-----------------------------------------------------------------------------
新建文件=》Add Sprites 添加图片之后,就可以根据图片进行编辑,编辑方法很简单
基本上就这几个按钮:
第一个是添加一个圆形刚体
第二个是添加多边形刚体
第三个看着想PS里面的魔棒工具,作用就是根据图片的边缘自动描绘
后面两个是翻转。
编辑好之后点publish就可导出我们需要的xml文件了。
如下
<exporter>
<!-- identifier of the exporter -->
<name>box2d-alchemy</name>
<!-- name for the dropbox -->
<displayName>CitrusEngine ActionScript (FLASH)</displayName>
<!-- description of the exporter -->
<description>CitrusEngine ActionScript for Flash</description>
<!-- exporter version -->
<version>1.0</version>
<!-- direction of the y axis: up / down -->
<yAxisDirection>down</yAxisDirection>
<!-- physics engine to use: box2d, chipmunk -->
<physicsEngine>box2d</physicsEngine>
<!-- name of the template file -->
<template>citrusengine.as</template>
<!-- file exension for the data file -->
<fileExtension>as</fileExtension>
<!-- anchor point settings -->
<anchorPoint>
<!-- are anchor points supported ? yes/no -->
<enabled>no</enabled>
<!-- relative position of the default anchor point -->
<relX>0.0</relX>
<relY>0.0</relY>
</anchorPoint>
<origin>
<!--
origin (0/0) point of the polygons
can be set to "anchorPoint" or "fixed"
Use
<relX>0.5</relX>
<relY>0.5</relY>
to specify a fixed origin.
Default is 0.5/0.5
-->
<type>fixed</type>
<relX>0.0</relX>
<relY>1.0</relY>
</origin>
<!-- custom global parameters -->
<global>
</global>
<!-- custom body parameters -->
<body>
</body>
<!-- custom fixture parameters -->
<fixture>
<parameter>
<name>density</name>
<displayName>Density</displayName>
<description>Density of the shape. Used for calculating the mass.</description>
<shortDescription>Density of the shape. Used for calculating the mass.</shortDescription>
<type>float</type>
<default>1</default>
</parameter>
<parameter>
<name>friction</name>
<description>Fricion.</description>
<shortDescription>Friction.</shortDescription>
<displayName>Friction</displayName>
<type>float</type>
<default>0.6</default>
</parameter>
<parameter>
<name>restitution</name>
<displayName>Restitution</displayName>
<description>Restitution defines how much a shape bounces.</description>
<shortDescription>Density of the shape. Used for calculating the mass.</shortDescription>
<type>float</type>
<default>0.3</default>
</parameter>
</fixture>
</exporter>
使用方法:
var pe:PhysicsEditorObjects = new PhysicsEditorObjects("Pe", {x:200, peObject:"muffin", view:"muffin.png", registration:"topLeft"})
add(pe);
PhysicsEditor template zip file.
PhysicsEditor example zip file.