制作as3龙息

发布于 2024-11-03 03:09:33 字数 210 浏览 1 评论 0原文

好吧,我有一个名为 dracoplay 的MC,里面有另一个名为 Drakep 的MC,里面还有另一个名为 wing 和 head 的MC,你可能已经猜到它们组成了一条龙。所以 dracoplay 是被编码的角色。 Drakp 是身体,头部和翅膀有动画。现在我的问题是让它喷火,这样它就会一直开火,直到我松开左键(我已经找到了一种方法,当我单击时它会开火,但我必须再次单击才能停止)。我还想让它向鼠标射击。

Ok i have a mc called dracoplay and inside is another mc called Drakep and inside that there is another mc called wing and head as you may have guessed they make up a dragon. So dracoplay is the character that gets coded. Drakp is the body and the head and wing have animations. Now my problem is making it breath fire so that it will keep firing until i let go of the left click (I already found a way for it fire when i click but i have to click again for it to stop). I would also like for it to shoot towards the mouse.

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

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

发布评论

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

评论(1

回首观望 2024-11-10 03:09:33

从我所看到的,您应该使用两个事件监听器,一个 mouseDown 和 mouseUp-event :) 我将编写一些基本代码来帮助您。

public function constructor():void
{
     stage.addEventListener(MouseEvent.MOUSE_DOWN, toggleFire);
     stage.addEventListener(MouseEvent.MOUSE_UP, toggleFire);
}

这两个事件监听器应该添加到代码的构造函数中。然后,toggleFire 方法将如下所示:

private function toggleFire(e:MouseEvent):void
{
     if(e.type == MouseEvent.MOUSE_DOWN)
          stage.addEventListener(Event.ENTER_FRAME, breatheFire);
     else
          stage.removeEventListener(Event.ENTER_FRAME, breatheFire);
}

您需要的最后一个函数是 BreathFire 函数。

private function breatheFire(e:Event):void
{
     //Write your code for the fire breathing here
}

这应该可以解决问题。

from what i'm seeing, you should use two eventListeners, a mouseDown and mouseUp-event :) I'll write some basic code that should help you.

public function constructor():void
{
     stage.addEventListener(MouseEvent.MOUSE_DOWN, toggleFire);
     stage.addEventListener(MouseEvent.MOUSE_UP, toggleFire);
}

these two eventListeners should be added in the constructor of your code. Then, the toggleFire-method will look like this:

private function toggleFire(e:MouseEvent):void
{
     if(e.type == MouseEvent.MOUSE_DOWN)
          stage.addEventListener(Event.ENTER_FRAME, breatheFire);
     else
          stage.removeEventListener(Event.ENTER_FRAME, breatheFire);
}

the last function you need is the breatheFire-function.

private function breatheFire(e:Event):void
{
     //Write your code for the fire breathing here
}

and this should do the trick.

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