使用 Tweener 补间 MC 缓慢移动时出现问题,即使进行平滑处理
我认为 Tweener 没有在 x,y 移动上使用像素分数,但这正是我所需要的。我读到有关 rounded 参数(默认值:false),该参数会将像素舍入,以减少文本问题,但我想慢慢平移加载的图像,所以我不想使用舍入值。我的代码:
var bmp = Bitmap(loader.content);
bmp.smoothing = true;
Tweener.addTween(loader, {x: 20.0, time:10, transition:"linear"});
图像平滑工作正常,但滑动时不稳定。它看起来像是在很少的帧上移动 1 个像素,而不是每帧移动 px 的一小部分。我正在考虑闪光图像平滑必须处理像素的一小部分。我在 stackoverflow 上进行了搜索,我所能找到的只是关于图像平滑,而不是关于 x,y 运动平滑。
提前致谢。
I think that Tweener is not using fractions of pixels on x,y movement, but that exactly what I need. I read about rounded parameter (default:false), that would round pixels, to reduce problems with text, but I want to slowly pan an loaded image, so I don't want to use a rounded value. My code:
var bmp = Bitmap(loader.content);
bmp.smoothing = true;
Tweener.addTween(loader, {x: 20.0, time:10, transition:"linear"});
Image smoothing works fine, but it slides choppy. It looks like moving 1 pixel at seldom frames, not some fraction of px per frame. I'm considering that flash image smoothing has to deal with fraction of pixels. I searched over stackoverflow, and all I could find was about image smoothing, and not about x,y movement smoothing.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果 loader.content 包含 Bitmap 实例,那就是你的问题。与 MovieClip 和 Sprite 不同,位图会自动捕捉到完整像素。您可以通过设置 PixelSnapping 属性来更改此行为。
If loader.content contains a Bitmap instance, that is your problem. Bitmap automatically snap to a full pixel unlike MovieClip and Sprite. You can change this behavior by setting the pixelSnapping property.
如果仅在某些不频繁的帧上出现断断续续的情况,则可能是垃圾收集器在您的运动中间进行了扫描,导致性能出现轻微的卡顿。
If it's choppy only on certain, infrequent frames, it could be the garbage collector doing a sweep in the middle of your movement and causing a slight stutter in performance.
我通过将 x,y 运动更改为scaleX 和scaleY“运动”来解决这个问题。由于我在一张大照片上使用了蒙版,当我缩放照片时,它看起来像是在移动,但实际上是在缩放。
我知道这不是一个好的答案,但它暂时解决了我的问题,因为我现在不知道为什么在这种特定情况下 x,y 运动不平滑。也许可以帮助有同样问题的人。
I solved this by changing x,y movement to a scaleX and scaleY "movement". As I was using a mask over a big photo, it looks like moving when I scale the photo, but it actualy is scaling.
I know this is not a good answer, but it temporarily solved my problem, since I didn't realy now why in this specific case x,y movement was not smooth. Maybe helps someone with same problem.