actionscript wiederholt sich [Flash 10]
| Beiträge: 4 Registriert: Apr 2013
| 28.04.2013, 20:52
ich habe 3 frames
in frame eins ist das spiel mein hero vs enemy
frame 2 ist gameover und restart
frame 3 ist level 2
mein problem ist das in frame 2 wenn ich sterbe noch meine enemys zusehen sind...obwohl sie nur in frame 1 gesetzt sind und die as auch in frame 1 liegt und nicht im zweiten frame
was mache ich falsch
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | stop();
start(secondsoffset,loop);
_root.score = 0;
var laser = new Sound();
laser.attachSound("laser");
var explode = new Sound();
explode.attachSound("explode");
var gold = new Sound();
gold.attachSound("gold");
/*var music = new Sound();
music.attachSound("musicloop");
music.start();*/
var numEnemy = 3;
var numCoin = 1;
var fire = false;
function moveHero(speed)
{
//check if key is down
if (Key.isDown(Key.UP))
{
_root.hero._y -= speed;
}
else if (Key.isDown(Key.LEFT))
{
_root.hero._x -= speed;
}
else if (Key.isDown(Key.DOWN))
{
_root.hero._y += speed;
}
else if (Key.isDown(Key.RIGHT))
{
_root.hero._x += speed;
}
if (Key.isDown(Key.SPACE))
{
if (fire == false)
{
fireBullets();
}
}
}
var i = 1;
function fireBullets()
{
i++;
fire = true;
_root.hero.gotoAndPlay(1);
laser.start();
var newname = "bullet" + i;
_root.attachMovie("bullet",newname,i * 100);
_root[newname]._y = _root.hero._y + 3;
_root[newname]._x = _root.hero._x + 92;
_root[newname].onEnterFrame = function()
{
var bullet_speed = 11;
this._x += bullet_speed;
if (this._x > 800)
{
this.removeMovieClip();
}
for (var h = 1; h <= numEnemy; h++)
{
if (this.hitTest(_root["enemy" + h]))
{
this.removeMovieClip();
_root["enemy" + h].gotoAndPlay(29);
explode.start();
}
}
};
}
function Enemys()
{
for (j = 2; j <= numEnemy; j++)
{
var name = "enemy" + j;
_root.enemy1.duplicateMovieClip(name,j);
}
}
Enemys();
function Coins()
{
for (g = 3; g <= numCoin; g++)
{
var name = "coin" + g;
_root.coin1.duplicateMovieClip(name,g);
if (this.hitTest(_root["coin" + h]))
{
this.removeMovieClip();
_root["coin" + h].gotoAndPlay(26);
}
}
}
Coins();
/*music.onSoundComplete = function() {
music.start();
}*/
_root.onEnterFrame = function()
{
moveHero(10);
};
|
| | | Beiträge: 1776 Wohnort: Laimbach 6 1/2 Registriert: Nov 2002
| 11.05.2013, 21:53
|
|