FlashDevelop:陡坡上的 AS3 补间停止
我正在使用 caurina.transitions.Tweener;我使用 AS3 类通过我的 3D 环境(使用 alternativa3D 平台创建)从 A 点到 B 点补间 3D 对象。一切都很好,它们按照预期从原来的位置移动到我告诉它们去的位置。
我想知道如果他们试图走过的斜坡太陡(就像现实生活中的一座巨大的山丘或山脉),是否有办法让物体停止移动(或补间)?
这基本上是我为此使用的代码:
var playerDistance: Number = Vector3D.distance(
new Vector3D( _escapeeManager.activeEscapee.x,
_escapeeManager.activeEscapee.y,
_escapeeManager.activeEscapee.z ),
intersectData.point );
Tweener.addTween( _escapeeManager.activeEscapee, { x:intersectData.point.x, y:intersectData.point.y, time:(playerDistance/_escapeeManager.activeEscapee.speed), transition:"linear" } );
如果您想查看我正在开发的游戏中的示例,可以在这里找到: http://redmenmusic.ca/godsend.html
感谢您的帮助!
I'm using the caurina.transitions.Tweener; class with AS3 to tween a 3D object through my 3D environment (created with alternativa3D platform) from point A to point B. And everything works great, they move as intended from where they were to where I told them to go.
I was wondering if there was a way to make the object stop moving (or tweening) if the slope they were trying to walk over was too steep (like a giant hill or mountain in real life)?
This is basically the code I am using for this:
var playerDistance: Number = Vector3D.distance(
new Vector3D( _escapeeManager.activeEscapee.x,
_escapeeManager.activeEscapee.y,
_escapeeManager.activeEscapee.z ),
intersectData.point );
Tweener.addTween( _escapeeManager.activeEscapee, { x:intersectData.point.x, y:intersectData.point.y, time:(playerDistance/_escapeeManager.activeEscapee.speed), transition:"linear" } );
And if you'd like to see an example in the game I'm developing, it can be found here:
http://redmenmusic.ca/godsend.html
Thanks for your help guys!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 Tweener 用于除表面动画之外的任何内容似乎有点奇怪 - 您可能需要实现一个更复杂的系统来处理对象移动、碰撞检测、斜坡等。
It seems a bit odd to use Tweener for anything other than superficial animations - you probably need to implement a more complex system to handle object movement, collision detection, slopes etc.
caurina.transitions.Tweener 有一些属性可以方便地解决您的问题。我并不是说 Tweener 是最好的方法,我猜它会让你到达你想要的地方:)。
Tweener 官方文档网站可以在这里找到:http://hosted.zeh。 com.br/tweener/docs/en-us/。 “补间参数”部分对您来说会很有趣。
因此,对于您的问题,我建议您这样处理:
每次更新 Tweener 时都会执行一个 onUpdate 事件。每次更新时,您都可以检查坡度是否太陡。
例子:
Tweener.addTween(myMovieClip, { x:100, time:1, onUpdate:function() { /* 在此检查 slode 是否陡峭 - 如果是,您可以移除对象上的 Tweener 并继续执行其他功能 */ }});
我希望它很清楚:)
祝你好运!
The caurina.transitions.Tweener has some properties that could come by handy for your problem. I'am not saying it's the Tweener is the best way, bit it will get you where you want I guess :).
The official Tweener documentation website can be found here: http://hosted.zeh.com.br/tweener/docs/en-us/. The section 'Tweening parameters' would be a interesting read for you.
So for your problem, I would suggest to approach it this way:
There is a onUpdate event which is executed on every update of the Tweener. On every update you could check if the slope is to steep or not.
Example:
Tweener.addTween(myMovieClip, { x:100, time:1, onUpdate:function() { /* check here if the slode is to steep - if it is you can remove the Tweener on the object and proceed with an other function */ }});
I hope it's clear :)
Good luck!