修改导出模板解决PhysicsEditor选择CitrusEngine导出的问题

前一篇文章提到如何修改导出后的文件来解决PhysicsEditor选择CitrusEngine导出的问题,这样每次导出后都要修改,其实还有一个一劳永逸的方法,就是修改PhysicsEditor的CitrusEngine模板,具体方法如下:
找到PhysicsEditor的安装路径,进入其bin\exporters\citrus-engine目录下,用你最喜欢的文本编辑器(推荐Sublime)打开citrusengine.as文件,将Box2DAS.Collision.Shapes.b2PolygonShape替换成Box2D.Collision.Shapes.b2PolygonShape,将Box2DAS.Common.V2替换成Box2D.Common.Math.b2Vec2,将com.citrusengine.objects.PhysicsObject替换成citrus.objects.Box2DPhysicsObject,最后再将文件中所有用到V2这个类的地方全部替换成b2Vec2。

PhysicsEditor选择CitrusEngine导出的问题

PhysicsEditor(1.0.10)中选择以Citrus Engine导出的类不能在Citrus Engine中直接使用,可能是PhysicsEditor是根据老版本的Citrus Engine导出的,导出的类结构如下:

import Box2DAS.Collision.Shapes.b2PolygonShape;
import Box2DAS.Common.V2;

import com.citrusengine.objects.PhysicsObject;

/**
* @author Aymeric
* <p>This is a class created by the software http://www.physicseditor.de/</p>
* <p>Just select the CitrusEngine template, upload your png picture, set polygons and export.</p>
* <p>Be careful, the registration point is topLeft !</p>
* @param peObject : the name of the png file
*/
public class PhysicsEditorObjects extends PhysicsObject  {
    ...
}

而Box2DAS.Collision.Shapes.b2PolygonShape、Box2DAS.Common.V2和com.citrusengine.objects.PhysicsObject类在Citrus Engine中并不存在,编译当然出错,其实只需要将Box2DAS.Collision.Shapes.b2PolygonShape替换成Box2D.Collision.Shapes.b2PolygonShape,将Box2DAS.Common.V2替换成Box2D.Common.Math.b2Vec2,将com.citrusengine.objects.PhysicsObject替换成citrus.objects.Box2DPhysicsObject,就可以在Citrus Engine中使用了。