【问题标题】:TweenLite sequence with no delay in between individual tweenTweenLite 序列,在各个补间之间没有延迟
【发布时间】:2012-03-13 08:50:22
【问题描述】:

我正在开发一个游戏并实现了寻路算法。我的寻路返回给我一个节点数组,角色必须通过这些节点才能到达目的地。基本上我需要逐个节点补间,所以我使用 TimelineLite 并将所有补间添加到序列中。有用。

然而,

节点之间的补间存在延迟(角色移动,然后停止,然后再次移动......),我无法弄清楚原因。我该如何解决?

代码如下:

    public function walk(startNode:Node,destinationNode:Node):void{
//retrieve the path of the character
            var path:Array = Pathfinder.findPath(startNode,destinationNode,GenericMap.findConnectedNodes);
            currentPath=path;
            if(path!=null){
                var pastX:Number;
                var pastY:Number;
                for(var index:int=0;index<path.length;index++)
                {
                    var currentNode:Node = path[index] as Node;
                    testMoveThroughNodes(currentNode.x,currentNode.y);
                }
            }
        }
        private var speed:Number = 0.7;
        private var timeline:TimelineLite = new TimelineLite();
        /** tween the sprite through nodes of path*/

        private function testMoveThroughNodes(targetX:Number,targetY:Number):void{
            timeline.append(new TweenLite(monster,speed,{x:targetX,y:targetY}));
        }

我可以对 TweenLite 排序的每个节点进行补间,但是它移动、停止和移动,看起来完全不自然。

【问题讨论】:

  • 我添加了代码。请帮帮我。

标签: apache-flex actionscript gsap


【解决方案1】:

是的,如果没有看到任何代码就很难说,但我想知道这是否只是一个缓和问题,它看起来就像事情正在短暂停止,尽管实际上并没有。请记住,默认缓动是 Quad.easeOut,因此在每个补间结束时移动会减慢(以获得更自然的“感觉”)。如果你想要线性运动,你可以使用 Linear.easeNone。

【讨论】:

  • 我很确定这也是问题所在,您只需要做new TweenLite(monster,speed,{x:targetX,y:targetY, ease:Linear.easeNone}) 就可以了。
【解决方案2】:

当你创建一个新路径时,可能会不断更新他的位置,所以 character.x 和 y 立即更新,这是你的问题还是动画本身,如果这样创建一个 switch ex();

 var switching = 0;
 if(switching >0){
    character.animationWalk.play();
 }

 if(switching <0){
    character.animationWalk.stop();
 }

以下是我为好玩而制作的文件,但它在 as2 中有很好的时间和动画控制,但概念是相同的。附上源文件。

http://ffiles.com/flash/games/sonic_hd_basic_sounds_animation_and_vector_3436.html

BJM 悉尼

【讨论】:

  • 我添加了代码。我认为问题出在补间引擎本身,而不是角色位置。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-05
  • 1970-01-01
  • 1970-01-01
  • 2023-03-03
  • 2012-09-22
  • 1970-01-01
相关资源
最近更新 更多