从画布中重绘闪存中的区域?
我目前正在构建一个池塘闪光应用程序,它具有水波纹效果,当它被渲染时,水波纹效果不在我的鼠标位置,而实际上我的函数使它在我的鼠标位置上绘制。我在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?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您需要检查 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?
我找到了解决这个问题的方法,只有当我的鱼游向靠近画布最大 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.