AS3 1084:语法错误:在冒号之前期待右键

时间:2014-06-13 12:11:13

标签: actionscript-3 flash

我试图制作一个AS3射击游戏,这是一个从右到左的玩家。 我想这样做,当我拍摄(spawnKogel)时,shootAllow变为假,然后启动kogelCheck,检查子弹(Kogel)是否< -10。如果那是真的,则shootAllow变为True,我可以再次拍摄。

但是当我尝试初始化kogelCheck时,我在spawnKogel的末尾得到了标题中的错误。这是我的代码:

package 
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.ui.Keyboard;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.media.Sound;
import flash.utils.Timer;
import flash.events.TimerEvent;

public class amateurodius extends MovieClip
{
    public var schip:ruimteschip = new ruimteschip();
    public var Kogel = new Bullet();
    var sound = new lazor();
    var BGM = new Muziek();
    var backdrop = new background();
    var shootAllow:Boolean = true;

    public function amateurodius()
    {
        addEventListener(Event.ADDED_TO_STAGE, initialize);
        addEventListener(Event.ENTER_FRAME, vijandmaken);
        stage.addEventListener(KeyboardEvent.KEY_DOWN, spawnKogel);
        addEventListener(Event.ENTER_FRAME, kogelCheck);
        Mouse.hide();
    }

    function initialize(e:Event)
    {
        addChild(backdrop);
        addChild(schip);
        BGM.play();
    }

    function spawnKogel(e:KeyboardEvent):void
    {
        if (shootAllow == true)
        {
            if (e.keyCode == Keyboard.SPACE)
            {
                addChild(Kogel);
                Kogel.x = schip.x;
                Kogel.y = schip.y;
                sound.play();
                shootAllow = false;
                kogelCheck (e:Event);
            }
        }
    }

    function kogelCheck (e:Event)
    {
        if (Kogel.x < -30)
        {
        shootAllow == true;
        }
        else
        {
        shootAllow == false;
        }
    }

1 个答案:

答案 0 :(得分:1)

在致电kogelCheck时删除活动类型:

// Just passing on the event, doesn't need type declaration
kogelCheck (e);