使用PhysicsEditor编辑Citrus Engine可用的模板

最近在学习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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值