简体   繁体   English

在gamequery; 如何将对象从“放置”位置“缓慢”移动到需要移动的位置?

[英]in gamequery; how would I move an object “slowly” from its “dropped” location to where it needs to go?

I am not trying to get it to follow a set path since the path is variable. 由于路径是可变的,因此我不试图使其遵循设定的路径。 but I am trying to set the object to fall in a noticable pattern from where Idrop it. 但我尝试将对象设置为从放置位置开始以明显的方式掉落。

$(".gQ_sprite").mouseup(function() {        

        //test condition to see if collides with a box etc...
        collision1 = $("#" + currentClickedDivId).collision(".gQ_group, .box");
        if(collision1.length > 0)
        {
                       //irrelevent
        }
        else
        {
            //figure out yarnball Id...
            i = wordLength - 1
            yarnBallIdNumber = currentClickedDivId.charAt(10);
            yarnBallPositionFromStart = i - yarnBallIdNumber
            initialMovedYarnBallXPosition = yarnBallPositionFromStart * yarnSpacing

            initialMovedYarnBallXPosition = initialXYarnPosition - initialMovedYarnBallXPosition


            $("#" + currentClickedDivId).xy(initialMovedYarnBallXPosition ,yarnYPosition);
        }

right now my code simply flashes the object back to its location after the user releases it, and I am trying to move it back "slowly" if you will and can't think of the best way to do it. 现在,我的代码只是在用户释放对象之后将其闪回它的位置,并且如果您愿意并且无法想到实现它的最佳方法,我将尝试“缓慢地”将其移回。

so far my thoughts are to use a loop and subtract (or add) the location of the object with delay, but there may be a better way to move the object that I don't know about. 到目前为止,我的想法是使用循环并延迟地减去(或增加)对象的位置,但是可能有更好的方法来移动我不知道的对象。

any ideas? 有任何想法吗?

What you could do is to use jQuery to animate something else than a CSS property, like explained there: https://coderwall.com/p/fn2ysa 您可以做的是使用jQuery为CSS属性之外的其他事物设置动画,如此处所述: https : //coderwall.com/p/fn2ysa

In your case to make your sprite move from currentX to destinationX in one second you code would look like: 为了使您的精灵在一秒钟内从currentX移到destinationX,您的代码应类似于:

var from    = {x: currentX};
var to      = {x: destinationX};
$(from).animate(to,{duration: 1000, step: function(step){
    $(mySprite).x(step);
}});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复此单击功能以缓慢移动到特定位置? - How do I fix this click function to move to a particular location slowly? 在gamequery中,我试图通过使用mousetracker单击对象并将其拖动来移动所选对象 - in gamequery I am trying to move a selected object with mousetracker by clicking on the object, and dragging it 我的 google 脚本执行速度很慢,但它已经从 107 行压缩到了 1 行。 我将如何 go 使其更具响应性? - My google script executes very slowly, but it has been condensed from just 107 lines to one. How would I go about making it more responsive? 如何缓慢移动DOM元素? - How I can move DOM elements slowly? 在Three.js中,如何在相机方向上直接将对象移离相机? - How would I move an object directly away from the camera in the camera direction in Three.js? Javascript mousemove animation 角度需要 go 慢慢回零 - Javascript mousemove animation angle needs to go slowly back to Zero 如何在选择文本的位置显示对象? - How can I show an object at the location where I select text? 我如何从对象中获得选择权? - How would I get options from object? 我将如何解决这种曼哈顿天际线/石墙的方法,哪里出了问题? 使用Javascript - How would I fix my approach to this Manhattan Skyline/Stone Wall and where did I go wrong? Javascript 你会如何看待用户输入{prefix} reddit {subreddit}的位置(然后回复该subreddit中的随机图像) - How would you go about where a user types in {prefix}reddit {subreddit} (then replies a random image from that subreddit)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM