A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: player score help

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

    player score help

    ok im having trouble making a player score. on tutorials it says u have to make a dynamic edit box but i dont know how to make the edit box dianamic. so thats my first question.

    second, this isnt a button pressing game like all the turtorials have, i want, after my sword collides with my clones badguys, i want the score to go up,

    so here is my script:

    for (i=0;i<num_badguy;i++) {
    if (element ("Sword").collideRect (badguy[i])) {

    badguy[i].unloadMovie();
    badguy.remove(i);
    num_badguy--;
    root.score = root.score+10;

    but sence the edit box isnt dynamic, my every time i kill a badguy my score just adds a 10 to it like this, if i kill 5 badguys it appears like this : 1010101010, which it really should be 50, so maybe my script is wrong, but im not sure how to make the edit box dynamic.

    if u know what the problem is please help,

    thanks

  2. #2
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    474
    ok, I have no idea what your script is all about but i can tell you how i do it. I would make an edit box and name it "score" lets say. (by the way make sure you name it under "varible" in the edit box instead of just the name of the edit box or it wont work, its under the "initialize with text" box). Then I would say

    if (element ("Sword").collideRect (badguy[i])){
    score+=10
    }

    ofcourse it will add 10 for every frame that the sword collides with your badguy, so your gona wanna make a code saying "if collide then hide badguy" and then youll have to make anither code saying, "if badguy hidden then dont add 10" or something
    Last edited by ConnELITE; 08-10-2005 at 02:33 PM.
    BC

  3. #3
    Senior Member
    Join Date
    Feb 2005
    Posts
    177
    but when i am attacking my badguys, i am removing the clone from the movie not hiding them, so i dont see what your saying. ill include a file maybe u can show me, because i am really confused.

    thanks
    Attached Files Attached Files

  4. #4
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    474
    nevermind what i said, i just kno i used to have problems with clones but if it works i guess its fine, here i fixed it and explained why in the collision script, i think it was because you need to set the editbox to a number first in the starting script
    Attached Files Attached Files
    BC

  5. #5
    Senior Member
    Join Date
    Feb 2005
    Posts
    177
    thanks a lot.


    i had a few minor bugs left but i got them worked out but thanks!
    Last edited by sonic04; 08-10-2005 at 11:20 PM.

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

    ?

    one last question, i have some text called win which says you won!, which is hidden. how can i show element "win" when lets say my score reaches 1000?

    thanks

  7. #7
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    474
    if (score>999){
    element ("win").show()
    }

    PS: if you your text is a movie do win.play()
    BC

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

    thanks

    ok thanks

  9. #9
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Quote Originally Posted by ConnELITE
    if (score>999){
    element ("win").show()
    }

    PS: if you your text is a movie do win.play()
    I think if you "show" a movie it will play anyway.

  10. #10
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Quote Originally Posted by sonic04
    every time i kill a badguy my score just adds a 10 to it like this, if i kill 5 badguys it appears like this : 1010101010, which it really should be 50, so maybe my script is wrong, but im not sure how to make the edit box dynamic.
    thanks
    Hi.

    For anyone else reading this and wondering, the reason is because the variable was being treated as a text variable and not a numeric variable.
    So if you say "10"+"10" the answer is "1010" but if you say 10+10 the answer is 20. It doesn't sound like there's a problem with the edit box itself.

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

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