模拟类似于灰尘颗粒的运动
我尝试过使用 css 和 animate 进行 setInterval
循环。两种运动方式都由 oldpos1 -> 的微小运动组成。 newpos1 没有随机曲线移动,但是 jQuery animate 发生了缓动,但仅在随机生成的 1-3 个像素之间发生,这不是我想要的 。 问题是否出在 setInterval
的时钟上,其中只有线性时间单位流动?
我应该从哪里开始,让下面的图像存在于 jQuery 中?
我想要做什么:
躲避行为:
A、B - 粒子
AB1 - 普通闪避区域,仅限一定量
2 运动:
Av、Bv - 随机圆周运动
Aacc、Bacc - 发生微小随机加速度的位置(在标记为更浓缩的虚线的图像上)
I've tried a setInterval
loop with css and animate. Both ways of movement consists of tiny movement from oldpos1 -> newpos1 with no random curve movement, easing however occured with jQuery animate but only between randomly generated 1-3 pixels, which is not what I want
.
Does the problem lies in setInterval
's clock, where only linear time units flow?
Where should I start, to make below images exist in jQuery?
What I would like to do:
Dodge behaviour:
A, B - particle
AB1 - common dodge area, only certain amount
2 Movement:
Av, Bv - random circular movement
Aacc, Bacc - where the tiny random acceleration occurs (on image marked as more condenced dashed lines)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不会依赖 jQuery 的 animate 来实现这一点,因为你的情况相当特殊......相反,使用“游戏循环模式”:有一个游戏对象,它保存一组移动的粒子(并碰撞......)然后定期绘制。
这是一个基本结构:
然后您可以根据需要操纵粒子的速度和方向,也许可以通过引入附加成员
d_speed
(加速度)和d_direction
等。I would not rely on jQuery's
animate
for this as your case is rather special ... instead, use the "game loop pattern": Have a game object which keeps a collection of particles, which are moved (and collided ...) and then drawn in regular intervals.Here's a basic structure:
Then you can manipulate speed and direction of particles as you like, maybe by introducing additional members
d_speed
(acceleration) andd_direction
or so.