0
我不得不爲學校製作這款簡單的遊戲,但作爲設計師,我並不擅長這類東西。Actionscript 3.0角色在拍攝時也會拍攝
問題是,當我按下空格鍵時發射子彈的事件在上下移動時也會發射子彈,而我不想這樣做。我知道這可能是一個愚蠢的錯誤,但請幫助我。我的遊戲是像太空射擊遊戲那樣的側滾輪遊戲。
此外,我想廣告拍攝動畫時,他拍攝的子彈,但它不會顯示,拍攝動畫我加入gotoAndstop(4);
這裏是我的所有代碼:
import flash.display.MovieClip;
import flash.sensors.Accelerometer;
import flash.events.Event;
var links:Boolean = false;
var rechts:Boolean = false;
var snelheid:int = 0;
var enemyy:MovieClip;
var enemies:MovieClip=new MovieClip();
stage.addChild(enemies);
for (var teller:int=1; teller<=20; teller++)
{
enemyy=new Blueenemy();
enemies.addChild(enemyy);
enemyy.x = 250 + 170 * teller + Math.round(Math.random() * 30);
enemyy.y = 50+ Math.round(300*Math.random());
}
stage.addEventListener(Event.ENTER_FRAME,altijd);
function altijd(evt:Event)
{
enemies.x -= 10;
}
stage.addEventListener(KeyboardEvent.KEY_DOWN,toets);
stage.addEventListener(KeyboardEvent.KEY_UP,toets);
main_mc.addEventListener(Event.ENTER_FRAME,lopen);
function toets(evt:KeyboardEvent):void
{
(evt.keyCode == Keyboard.SPACE);
{
var bullet:Bullet=new Bullet();
bullet.x = main_mc.x + 37;
bullet.y = main_mc.y + -10;
stage.addChild(bullet);
bullet.addEventListener(Event.ENTER_FRAME,beweeg);
function beweeg(evt:Event)
{
bullet.x += 15;
}
};
if (evt.keyCode == 38)
{
if (evt.type == "keyDown")
{
links = true;
main_mc.gotoAndStop(3);
snelheid = -15;
}
else
{
links = false;
}
}
if (evt.keyCode == 40)
{
if (evt.type == "keyDown")
{
rechts = true;
main_mc.gotoAndStop(2);
snelheid = 15;
}
else
{
rechts = false;
}
}
}
function lopen(evt:Event):void
{
main_mc.y += snelheid;
if (! links && ! rechts)
{
main_mc.gotoAndStop(1);
snelheid = 0;
}
}