PV3D+TweenLite——让3D镜头也缓动起来!

PV3D提供了一个BasicView的类,继承这个类,可以让我们轻易在舞台上创建镜头,3D对象。

        public function ThreeDStage(cameraType:String, owner:DisplayObject)
        
{
            
super(owner.width, owner.height, falsetrue, cameraType);

            
this.camera.focus = 30;
            
this.camera.zoom = 30;
            
            
for (var i:int = 0; i < 40; i ++)
            
{
                var ball:Ball 
= new Ball(src);
                scene.addChild(ball);
            }

        }

然后添加一个Timer对象,定时执行镜头的移动、旋转。

            timer = new Timer(40000);
            timer.addEventListener(TimerEvent.TIMER, onTimer);
            timer.start();

在这个监听函数里面,我们使用TweenLite类来移动和旋转镜头。

            TweenLite.goto(this.camera, 2.5{x:360 - Math.round(Math.random() * 720),
                                            y:
200 - Math.round(Math.random() * 400),
                                            z:
200 - Math.round(Math.random() * 400),
                                            rotationX:
40 - Math.round(Math.random() * 80),
                                            rotationY:
40 - Math.round(Math.random() * 80),
                                            rotationZ:
40 - Math.round(Math.random() * 80),
                                            ease:GetEasingFunction.easingFunction(_tweenType).easeOut,
                                            onComplete:_stopRendering}
);

这样我们的镜头就具备缓动效果了。
顺便说一下,在这个BasicView类里面,有三个方法,startRendering()和stopRendering()和singleRender()。第一个是开始每帧绘制3D对象,第二个是停止绘制3D对象,第三个是只绘制一次3D对象。

Preview:由于空间过期,请到我的blog查找更新的地址

posted @ 2008-07-04 01:47  牛牛猪  阅读(3177)  评论(1编辑  收藏  举报