How to count actor in the scene

calvin9403calvin9403 Member Posts: 3,186
edited November -1 in Working with GS (Mac)
I am making a game that has a lot of levels,I want to count my actor in the scene(so I can display the you win actor). I try the tutorial, but it did not work. Any proposal?

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    create a game attribute called actorcount

    Then put a change attribute behavior in the prototype of the actors that does
    change game.actorcount to game.actorcount +1

    Dont put it inside a rule and it will count all of that actor on the scene when it loads and increase anytime you spawn more of that actor in that scene.
  • calvin9403calvin9403 Member Posts: 3,186
    So what I do is change attribute game.object_count to game.object_count+1
    but it did not work
    BTW when the actor is destroy I what it to minus1, so I did when the lives =0, minus1 to the object_count
    P.S there will be a lot of the some actor in a scene
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Yes that is what you need to do. and in a destroy rule you need to add in a change attribute to do a game.object_count-1 also everytime the scene resets you need to do something to set it back to zero. like in a reset button or something
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Also drop an actor on the scene with a display text behavior to and set it to display game.object_count so you can see if its adding correctly. Also your attribute should be an integer
  • calvin9403calvin9403 Member Posts: 3,186
    the what is the value of the integer
    is it 0
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    yes it should be 0 for the default attribute then let each scene add it up and what not. Also when you click to advance to a new level you should set a rule to reset that to 0
  • calvin9403calvin9403 Member Posts: 3,186
    well, but if all the things is destroy ,it well be bake to zero
    and aiso, can you explain how will it work I can not let it the attribute add up
    I did this: drag the change attribute to the area the first box I said object_count to object_count-1
    is it corret
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I guess i'm not fully understanding what your wanting with the count.

    What you just typed is what will drop the count by 1 each time an actor is destroyed

    Can you explain more about your project and what you are using the count for?
  • calvin9403calvin9403 Member Posts: 3,186
    all right,
    I am doing a project like you use a ball to break the candy(something like crazy ball wall breaker )
    and I have a few question
    1.i want to make a you win screen after I beat the level,and I have 480 levels,so I have to do something like coin count,or if you have other way that helps
    2.if I have 5 same candy in a level, when I destroy one, others get destroy too,but i do not want that
    P.S. are you always going to be online
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    480 Levels Wow!! thats gonna be a big game.
    Based on the crazy ball wall breaker demo it should be a piece of cake to set up a "win Screen" based on the blocks count equaling 0 Not sure why it would destroy more than one unless your basing the destroy on attributes or something and not just a collide.

    Why don't you email me at tenrdrmer(at)yahoo.com so we talk more in detail about your project.

    And yeah i'm online alot. it kinda comes and goes
  • calvin9403calvin9403 Member Posts: 3,186
    because some candy have more then one live, so I have to use attribute to do it
    and in the demo, there is only one level, but i have almost500, so i can not use that way
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Shoot me an email we can talk more there
  • calvin9403calvin9403 Member Posts: 3,186
    all right, I just did
  • calvin9403calvin9403 Member Posts: 3,186
    did you get my mail
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
  • calvin9403calvin9403 Member Posts: 3,186
    are you still there
Sign In or Register to comment.