dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: initialisestuff() errors

  1. #1
    Senior Member
    Join Date
    Feb 2005
    Posts
    177

    initialisestuff() errors

    ive been using intialise stuff() for my code to make my "levels" in my current games. With help i got it to work for my last game, but now that i started a new one i can only seem to get the first "case" to show.

    heres my code:

    level=1
    initialisestuff();



    function initialisestuff()
    {
    switch (level)
    {
    case 1 :
    num_Villian = 3
    break;
    case 2 :
    num_Villian = 4
    break;
    case 3 :
    num_Villian = 5
    break;
    }


    v = element ("Villian")


    Villian = new Array(num_Villian);
    for (i=0;i<num_Villian;i++) {
    Villian[i] = v.clone();
    Villian[i].x = 400+random(80);
    Villian[i].y = 60+random(250);
    Villian[i].acceleration.x = -random(50);
    }

    }

    im not sure whats wrong but ill leave a file in case u need it.

    by the way all of this code is in my starting script in case u want to take a look at whats wrong.

    thanks

    jaron
    Attached Files Attached Files

  2. #2
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Hi,

    I don't see any code that says,

    "When the number of villains is 0, then move to the next level, then run the initialisestuff function again"

    eg. In the main collision script:

    if (num_Villian<=0)
    {
    level+=1
    root.initialisestuff()
    }

    This will test to see if the number of villains is now less than or equal to 0, set the fact that you are now on the next level, and initialise things ready for that level.

    You have to use root.initialisestuff() because the function is in the starting script, and not in the script where this code is running.

    Morgan
    Please note that my domain has changed to http://www.morganmultinational.com

  3. #3
    Senior Member
    Join Date
    Feb 2005
    Posts
    177

    thanks

    ok thanks i totally forgot about the part in which it allows u to switch from level to level.

    thanks

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    177

    just a thought

    just a thought, but do u know how i can make a text element and have the text say whatever level i am on?

    would it be something like....


    text = level++ or something like that? i havent a clue but i thought u might

  5. #5
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Just create an edit box, and inside the editbox, in the field for variable, enter the name of your variable, which in this case is:

    'level'

    Easy as that
    Please note that my domain has changed to http://www.morganmultinational.com

  6. #6
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    and make sure you make it NOT editble!

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