AS3 ActionScript绘制大纲
我正在使用Adobe Air和AS3开发着着色游戏。我有一个带有黑色轮廓的图像,用户可以使用笔工具绘制图像。我需要帮助才能弄清楚如何限制用户仅在大纲中绘制。我已经尝试过用线条图形掩盖图像,但它悬挂了应用程序。对解决方案的任何提示 /建议都得到赞赏。
以下是Mouse_down事件上的代码
_dot = new MovieClip();
_dot.graphics.lineStyle(lineSize, color);
_dot.graphics.moveTo(img.mouseX,img.mouseY);
img.addChild(_dot);
I am developing a coloring game using adobe air and as3. I have an image with black outline and the user can draw / color the image using a pen tool. I need help to figure out how can I restrict the user to draw within the outlines only. Masking the image with the line-graphics is something I have tried but it hangs the application. Any hint / suggestion towards the solution is appreciated.
following is the code on mouse_down event
_dot = new MovieClip();
_dot.graphics.lineStyle(lineSize, color);
_dot.graphics.moveTo(img.mouseX,img.mouseY);
img.addChild(_dot);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您要绘制的区域是 displayObject ,其实例名称为 canvas 。您需要检查鼠标是否在画布上。
为此,您要使用 displayObject.hittestpoint(...)与 shapeflag 设置为 true (如果它是 false ,它将测试对象的矩形边界框,这将为任何框架产生错误的结果非矩形或旋转形状)。
因此,您按照以下操作:
Let's say, the area you are drawing on is a DisplayObject with an instance name of Canvas. What you need is to check if the mouse is on Canvas or not.
In order to do so, you want to use the DisplayObject.hitTestPoint(...) method with the shapeFlag set to true (if it is false, it tests the point against the object's rectangle bounding box, which would produce the wrong results for any non-rectangular or rotated shapes).
So, you do as following: