dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [help] stuck on actionscript help for my game

  1. #1
    Member
    Join Date
    May 2004
    Posts
    33

    [help] stuck on actionscript help for my game

    This is my first flash game and I've looked, but couldn't find tutorials for the coding I want to do so I've been really struggling trying to guess where stuff goes and piecing individual tutorials together- I'm doing good but i have two problems:

    1) when the laser hits the spaceship then you lose a life, when all lifes are gone then game over.
    code:
    onClipEvent (load) {
    var lives = 3;
    function reset(){
    this._y=-15;
    this._x=random(400);
    enemySpeed=random(10)+5;

    }

    reset();
    }
    onClipEvent (enterFrame) {
    this._y+=enemySpeed;



    if (this.hitTest( _root.spaceship ) ){
    lives-=1

    }
    if (lives < 3) {
    removeMovieClip(Life3);
    }
    if (lives < 2) {
    removeMovieClip(Life2);
    }
    if (lives < 1) {
    gotoAndPlay(517);
    }

    if (this._y>450) {
    reset();
    }
    if (this.hitTest( _root.spaceship ) ){
    removeMovieClip(this);

    }


    }




    2) I have a power bar, I make it go up and down like I want but I can't make it go to the frames like it should.
    code:
    onClipEvent(load){

    dropSpeed=10;
    upSpeed=3;

    }
    onClipEvent (enterFrame) {



    if (Key.isDown(Key.CONTROL) and this._y<400) {
    this._y+=dropSpeed;
    } else if (Key.isDown(Key.SHIFT) and this._y>245) {
    this._y-=upSpeed;
    }

    if (this._y>395) {
    gotoAndPlay(118);
    } else if (this._y<240) {
    gotoAndPlay(211);
    }
    }



    if someone could help me out with that or tell me how to make variables work please tell me because it seems like they don't do anything for me other than keep tract (I've already tried to switch frames based on score, but couldn't get it to even though scoring worked great)

  2. #2
    No ambitions beyond flash ScimSlave's Avatar
    Join Date
    Sep 2002
    Location
    Germany
    Posts
    131
    hmm maybe using this.gotoAndStop... would help.
    other thing.: using var .. means you create a local variable.. try using this.lives = 3; instead of var... use also this.lives to acces this variable but i don't see any errors there...
    good luck
    -i
    Dulce et decorum est pro Scim mori.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center