利用Label3D来规划和播放多动作模型

首先明确一下,Label3D是如何使用的:

new Label3D(WALK, 0, 41);
// 参数1:标签名称(String)
// 参数2:标签起始帧(int)
// 参数3:标签结束帧(int)

接下来是具体示例代码:

package
{
	import flare.basic.Scene3D;
	import flare.basic.Viewer3D;
	import flare.core.Label3D;
	import flare.core.Pivot3D;
	import flare.system.* //Input3D    

	import flash.display.*;
	import flash.events.Event;

	public class demo_anim extends Sprite
	{
		public static const WALK:String = "walk"
		public static const RUN:String = "run"

		private var scene:Scene3D;
		private var model:Pivot3D;
		private var walk:Label3D;
		private var run:Label3D;

		public function demo_anim()
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			scene = new Viewer3D( this );
			walk = new Label3D( WALK, 0, 41 );
			run = new Label3D( RUN, 50, 74 );
			scene.addEventListener( Scene3D.COMPLETE_EVENT, completeEvent );
			
			// flare3d 2.5.x开始已经不再支持f3d模型,全部使用 zf3d
			model = scene.addChildFromFile( "../resources/player.zf3d" );
		}

		protected function completeEvent( event:Event ):void
		{
			model.addLabel( walk );
			model.addLabel( run );
			model.gotoAndPlay( WALK );
			scene.addEventListener( Scene3D.UPDATE_EVENT, updateEvent );
		}

		protected function updateEvent( event:Event ):void
		{
			// 停止模型动作 - stop the model animation.
			if( Input3D.keyHit( Input3D.S ))
				model.stop();

			// 恢复模型动作 - resume the model animation.
			if( Input3D.keyHit( Input3D.P ))
				model.play();

			// 播放行走动作标签 - play certain animation label and blend between the animations.
			if( Input3D.keyHit( Input3D.NUMBER_1 ))
				model.gotoAndPlay( WALK, 15 );

			// 播放跑动动作标签
			if( Input3D.keyHit( Input3D.NUMBER_2 ))
				model.gotoAndPlay( RUN, 15 );

			// 恢复到第一帧
			if( Input3D.keyHit( Input3D.NUMBER_3 ))
				model.gotoAndStop( 0, 10 );

			// 增加帧播放速率 - increment and decrement frameSpeed.
			if( Input3D.keyHit( Input3D.NUMPAD_ADD ))
				model.frameSpeed += 0.5;

			// 减少帧播放速率
			if( Input3D.keyHit( Input3D.NUMPAD_SUBTRACT ))
				model.frameSpeed -= 0.5;

			// 重置播放速率 - reset the frameSpeed.
			if( Input3D.keyHit( Input3D.R ))
				model.frameSpeed = 1;
		}
	}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

喵大斯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值