从画布中重绘闪存中的区域?

发布于 2024-11-19 16:54:03 字数 862 浏览 1 评论 0原文

我目前正在构建一个池塘闪光应用程序,它具有水波纹效果,当它被渲染时,水波纹效果不在我的鼠标位置,而实际上我的函数使它在我的鼠标位置上绘制。我在Flash播放器上显示了重绘区域并附上了图片。有人知道如何解决这个问题吗? 在此处输入图像描述

addEventListener(MouseEvent.MOUSE_MOVE,onMouseMoveTriggered);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownTriggered);
private function onMouseMoveTriggered(e:Event):void {
            if (canPlay)
            {
            waterMovementSound.play();
            canPlay = false;
            soundTimer.start();
            }
            myRippler.drawRipple(stage.mouseX, stage.mouseY, 10, 0.9);

            //evt.stageX
            //evt.stageY
        }
        private function onMouseDownTriggered(e:Event):void {
            myRippler.drawRipple(stage.mouseX,stage.mouseY, 10, 0.9);
            stage.mouseX;
            stage.mouseY;


        }

i am currently building a pond flash application, and it has a water ripple effect , when it is rendered, the water ripple effect is not at my mouse position when in fact my function makes it draws on my mouse position. i did a show redraw region on the flash player and attached is the picture.does anyone know how to solve this problem?
enter image description here

addEventListener(MouseEvent.MOUSE_MOVE,onMouseMoveTriggered);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownTriggered);
private function onMouseMoveTriggered(e:Event):void {
            if (canPlay)
            {
            waterMovementSound.play();
            canPlay = false;
            soundTimer.start();
            }
            myRippler.drawRipple(stage.mouseX, stage.mouseY, 10, 0.9);

            //evt.stageX
            //evt.stageY
        }
        private function onMouseDownTriggered(e:Event):void {
            myRippler.drawRipple(stage.mouseX,stage.mouseY, 10, 0.9);
            stage.mouseX;
            stage.mouseY;


        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奶气 2024-11-26 16:54:03

我认为您需要检查 stage.align 是否设置为 topLeft 且 stage.scaleMode 设置为 noScale,除非您实际上需要进行不同的设置。

如果您仍然遇到问题,那么这可能是因为您正在嵌套容器(Sprite、DisplayObject 等)内进行绘制,并且该容器是偏移的。如果是这样的话,您可以使用 globalToLocal 来解决有关鼠标的位置问题吗?

I would think you need to check that the stage.align is set to topLeft and stage.scaleMode is set to noScale, unless you actually need to have differing setup.

If you've still got issues then this could possibly be because you're drawing inside a nested container (Sprite,DisplayObject,etc) and that is offset. If that's the case you could use globalToLocal to solve the issue of positional problems concerning mouse?

水波映月 2024-11-26 16:54:03

我找到了解决这个问题的方法,只有当我的鱼游向靠近画布最大 Y 和最大 X 的随机 x,y 点时,效果才会移动,因此我将鱼生成的随机 XY 值减少为游动的距离远小于 max Y 和 max X,因此它不会游近边缘。

I found a work around to this problem, the effects only move out of place when my fishes are swimming towards a random x,y point near to the canvas max Y and max X, so i reduced the generated random XY values for the fishes to swim to by much lesser than max Y and max X, therefore it wont swim close to the edges.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文